Click here to Skip to main content
15,888,113 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
So I have run across a few applications that have thumbnail toolbar buttons that aren't buttons. They are just images without the button border. One instance is in Windows itself when I plug in my Nikon camera. It shows the battery status as just an Icon and not a full button. Here[^] is what it looks like. Another instance of this is here.[^] This has the four buttons and then the space, which I assume is what I am trying to do but with a blank icon. Does anyone know how to accomplish this with VB.Net using the Windows API Code Pack (or any other way for that matter)?

Thanks in advance! :)
Ethan
Posted

1 solution

A couple of ways to get it done...

You can use a button, but set its FlatStyle property to Flat and BorderWidth property to 0. Add an image to the button and you're good to go.

Another way is to dock a TableLayoutPanel in the form and add PictureBox controls to it. Set the Image property of each PictureBox to the image of your choice, and handle the Click event for each one the same as handling a button's Click event.

You can set the Padding property of the TableLayoutPanel to put some space between the PictureBox controls, and its CellBorder property to give it a nice look. Check out this[^] article to see flat buttons used within a TableLayoutPanel in the screen capture image.

You can of course draw images directly onto the client area and handle the MouseMove and MouseDown events, but that's a bit more involved to code and probably not as fast as the methods described above.

Hope this was helpful.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900