|
-
May 14th, 2010, 08:23 PM
#1
Thread Starter
Lively Member
.NET Component Resources?
How could I get the icons for components in the toolbox into .ico or .bmp or whatever image format they are in, I've looked through system32 etc etc and searched online for hours but I just can't figure out how to get specific control's icons (like a textbox's).
-
May 14th, 2010, 08:56 PM
#2
Re: .NET Component Resources?
Have a look at
System.Drawing.Icon
System.Drawing.Bitmap
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
May 14th, 2010, 11:51 PM
#3
Re: .NET Component Resources?
1) Not sure why you're after the icons... and 2) not sure why you're looking in the system32 folder since the icons are in the controls themselves.
-tg
-
May 15th, 2010, 04:10 PM
#4
Re: .NET Component Resources?
The attribute is ToolBoxBitmap, and you can use reflection to get the icon. I'm looking now on MSDN for the method names...
Last edited by minitech; May 15th, 2010 at 04:22 PM.
-
May 15th, 2010, 04:24 PM
#5
Re: .NET Component Resources?
Code:
Dim t As Type = GetType(TextBox)
Dim d As IList(Of CustomAttributeData) = CustomAttributeData.GetCustomAttributes(t)
For Each attr As CustomAttributeData In d
If attr.ToString().IndexOf("ToolboxBitmap") > -1 Then
Dim bmp As Bitmap = Bitmap.FromFile(attr.NamedArguments(0).ToString().Split("="c)(1))
Me.PictureBox1.Image = bmp
Exit For
End If
Next
This doesn't work for embedded resources, though... I'm not sure if the TextBox works that way. However, you can get the assembly name and the resource name:
Code:
Dim t As Type = GetType(TextBox)
Dim d As IList(Of CustomAttributeData) = CustomAttributeData.GetCustomAttributes(t)
For Each attr As CustomAttributeData In d
If attr.ToString().IndexOf("ToolboxBitmap") > -1 Then
Dim assemblyName As String = attr.NamedArguments(0).ToString().Split("="c)(1)
Dim resourceFile As String = ""
If attr.NamedArguments.Count > 1 Then resourceFile = attr.NamedArguments(1).ToString().Split("="c)(1)
MessageBox.Show("The bitmap is in the assembly """ & assemblyName & """ and the resource name of the bitmap is """ & resourceFile & """.")
Exit For
End If
Next
Last edited by minitech; May 15th, 2010 at 04:37 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|