- 題名: コントロールのイメージを取得する方法は?
- 日時: 2009/06/23 16:03:49
- ID: 24806
- この記事の返信元:
- (なし)
- この記事への返信:
- [24808] Re[1]: コントロールのイメージを取得する方法は?2009/06/23 17:16:13 [解決]
- ツリーを表示
すみません。自己レスです。
ヘルプ(ToolboxBitmapAttribute.GetImage メソッド)に書いてありました。
失礼しました。
以下、抜粋。
Private Function GetImageOfCustomControl(ByVal userControl As Control) As Image
Dim controlImage As Image = Nothing
Dim attrCol As AttributeCollection = TypeDescriptor.GetAttributes(userControl)
Dim imageAttr As ToolboxBitmapAttribute = _
CType(attrCol(GetType(ToolboxBitmapAttribute)), ToolboxBitmapAttribute)
If (imageAttr IsNot Nothing) Then
controlImage = imageAttr.GetImage(userControl)
End If
Return controlImage
End Function
いつもお世話になります。
カスタムコントロールを作成時にツールボックスに表示される画像の変更方法などは、掲示板にも投稿されておりますが、
逆に、コントロールの画像を取得する方法を検索しても見つけられませんでした。
Controlオブジェクトから取得する方法を教えていただけませんでしょうか?
よろしくお願いいたします。