Results 1 to 2 of 2

Thread: VB.net/c# HowTo add bitmap's to your user controls

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489

    VB.net/c# HowTo add bitmap's to your user controls

    If you've ever created a user control, particularly an inherited control, you've noticed that the icon to the left of your new control in the toolbox is simply a gear. With the below code, you can add the icon from an existing control:

    VB Code:
    1. <ToolboxBitmap(GetType(System.Windows.Forms.TextBox))> _
    2. Public Class TextBox
    3.     Inherits System.Windows.Forms.TextBox
    4.  
    5. End Class
    or in C#
    VB Code:
    1. [ToolboxBitmap(typeof(Button))]
    2. class MyControl1 : UserControl
    3. {
    4. }
    more information can be found Here
    Last edited by Andy; Apr 28th, 2005 at 02:15 PM.

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489

    Re: VB.net/c# HowTo add bitmap's to your user controls

    I learned of another method too:
    add a 16X16 BITMAP to the project and in the bitmap's property page, set the BuildAction to 'EmbeddedResource'...
    This puts the bitmap in the assembly file and becomes part of the code. When you add the compiled .dll to your toolbox, the icon will automatically be there.

    neat, huh?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width