i create a windows control and it is an advanced TextBox, now i want set a textbox icon for it that when i add it to my toolbox it shown as like as microsoft TextBox
You need to use the System.Drawing.ToolBoxBitmapAttribute class.
Visual Basic:
Imports System.Drawing
<ToolboxBitmap(GetType(MyTextBox), "NameOfResource")> _
Public Class MyTextBox
'...
End Class
C#:
using System.Drawing;
[ToolboxBitmap(typeof(MyTextBox), "NameOfResource")]
public class MyTextBox {
// ...
}
There are different overloads, but this is probably the best. You pass the name of the resource and an object type in your assembly so the constructor can find the assembly to extract the resouce.
The name of the resource isn't going to be the same as the name of the file. Depending on how it is added to the project, the name varies. It might be a good idea to compile the program, then decompile it with Reflector to find the name of the resource, then add the attribute.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.