Changing ToolstripButton BackgroundImage

Hi,
I have a problem whe I try to change the background image of a toolstripbutton. I implemented the MouseEnter and MouseLeave events change the backgroundimage:

System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
this->toolStripButton1->BackgroundImage = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"toolStripButton1.newBackgroundImage")));

(for the MouseEnter.. and similar to MouseLeave)

When I run the application and put the mouse over the button, it will change to an "empty" image, i.e., it will display the background color of the toolstrip control. I also wanted to change the background image when the button is checked but the same thing happen.

Am I missing something or this is the way it should be Do I have to do the rendering myself to do what I want

Note: I'm using the background image property instead of image property because I want my image to occupy the whole button's area.

Thank you,
Ricardo Sabino.



Answer this question

Changing ToolstripButton BackgroundImage

  • Stephie

    Ricardo,

    You might try doing this with the ToolStripItem class. If you're trying to do this, you don't really want the button functionality, as you are defining your own, so odds are the drawing logic in the ToolStripButton class is interfering with your efforts to draw this by hand. Go to the simpler version (ToolStripItem) and you may have better luck.

    Erik


  • Changing ToolstripButton BackgroundImage