ugp

How to change the Icon of a UserControl.

Normally, it appears in the ToolBar as something like a Purple color rounded flower.(Default)
How to change this.
I want to put a new Icon for that.!
Is it possible.

need help!



Re: Windows Forms General change the Icon of a UserControl.?

ARK88

Here is what I did:

  • Added a user control (named UserControl1) to a normal windows application project.
  • Added a bitmap (named UserControl1.bmp) to the same project.
  • Opened the bitmap for editing, resized it to 16x16, colored it a little, then saved and closed it.
  • Clicked once on the bitmap in the Solution Explorer window, then changed the "Build Action" property in the properties window to "Embedded Resource".
  • Opened the code editor for the user control, then added the following attribute info prior to the definition of my class:

[System.Drawing.ToolboxBitmap(typeof(UserControl1))]

  • - Built my application.

The icon did not automatically update in my toolbox after I did all that. So, I continued with this...

  • I right-clicked on my toolbox and selected "Choose Items...".
  • I scrolled through the list of .NET Framework Components until I found my UserControl1 in the list. I looked to see what directory it was pointing to and it was my "obj\Debug" folder.
  • I unchecked my UserControl1 item in that list, then clicked the "OK" button.
  • My user control was removed from the toolbox.
  • I right-clicked on my toolbox again and selected "Choose Items...".
  • I clicked the "Browse" button and navigated to my "obj\debug" folder (for my project) and selected my application's executable in that directory.
  • I clicked all the "OK" buttons to get back to my project, and my icon updated.

I'm not saying or recommending that the last portion above is the way to do it... but that's how I did it to get it to work.





Re: Windows Forms General change the Icon of a UserControl.?

ugp

Thanks ARK88

It works......





Re: Windows Forms General change the Icon of a UserControl.?

ugp

but here the problem is....

when close and open the solution those icons are miss out. It shows the default Icons again.

Is there a way to show it permanently...

need help!





Re: Windows Forms General change the Icon of a UserControl.?

ARK88

Seems to be more reliable when I built my user control in a control library, then referenced that component... any chance that is a viable option for you An additional benefit is that it would make your component reusable throughout your projects. Just a thought...