Draw ToolbarButton Image

T

Tom

Hi

Hi i am trying to draw on top of a button on a standard toolbar. All i
want to do is draw a small rectangle on the button to represent the
selected color.

I have tried the folowing code in the toolbar's parent control, which
is fired when the selected color is changed:

Dim r As Rectangle = FontColorButton.Rectangle
Dim g As Graphics = CreateGraphics()

g.FillRectangle(New SolidBrush(Color.Green), r)

This is not working, not really sure why, although i am pretty sure i
am approaching it from completely wrong angle.

Any help appreciated.

Thanks

Tom
 
K

Ken Tucker [MVP]

Hi,

Dim g As Graphics = ToolBar1.CreateGraphics
Dim r As Rectangle = ToolBarButton1.Rectangle

g.FillRectangle(New SolidBrush(Color.FromArgb(128, Color.Blue)), r)

Ken
 
H

Herfried K. Wagner [MVP]

* "Ken Tucker said:
Dim g As Graphics = ToolBar1.CreateGraphics
Dim r As Rectangle = ToolBarButton1.Rectangle

g.FillRectangle(New SolidBrush(Color.FromArgb(128, Color.Blue)), r)

.... but don't forget to dispose the brush ;-).
 
T

Tom

* "Ken Tucker said:
... but don't forget to dispose the brush ;-).

Thanks guys, i actually went back a bit and decided what i should be
doing is modifying the image that is displayed on the toolbarbutton,
rather than the button it's self.

Cheers

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top