Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
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 :rolleyes:
[ once4ever ]
  • Leaders
Posted

You need to use the System.Drawing.ToolBoxBitmapAttribute class.

Imports System.Drawing

<ToolboxBitmap(GetType(MyTextBox), "NameOfResource")> _
Public Class MyTextBox
   '...
End Class

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.

[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...