I want to push toolstripbutton down in my code and I can't seem to be able to do that. I know on Delphi RAD Studio or XE, you can do the following and cause the button to be pressed.
ToolStripButton1.Down := true;
The only ToolStripButton property I see that comes close to "down" is checked true or false. If I do set it to true, it only highlights the toolstripbutton not press it down.
Here is how the button looks when I put my mouse on it and click:

You can clearly see that the Zoom In button is down.
Here is how the button looks when I try to do the samething through my code by setting CheckOnClick true and Checked true.

In this image, the only thing you can see is the blue box around it. I suppose if I had used just the text on the button, you will see that the whole button filled with blue color to show that it was pressed.

I also have toolstrip button in my other program which acts the same way but I had to use imagelist control to switch between pressed or down or checked verses not pressed or down or checked.
So, is there a way to press the ToolStripButton programmatically in Delphi Prism or C#?
Set the
ToolStripButton.CheckOnClickproperty toTrue. (It's found in theBehaviorsection of theItems Collection Editor.)This makes clicking it just like toggling the
Downproperty in a DelphiTSpeedButton(making it flat or depressed), andif ToolStripButton1.Checkedis the equivalent ofif SpeedButton1.Downin Delphi.To set up the test, I did the following:
ToolStriponto the newMainFormToolStripButtonitems and gave them images to make them easier to see.CheckOnClickproperty toTruefor each of themCheckedproperty oftoolStripButton1toTrue;Added the code below to
toolStripButton1.Clickmethod MainForm.toolStripButton1_Click(sender: System.Object; e: System.EventArgs); begin toolStripButton2.Checked := not toolStripButton2.Checked; toolStripButton4.Checked := toolStripButton2.Checked; end;
Running the app (initial startup,
toolStripButton1checked and the others unchecked):The first button is clearly down, and the rest are up.
After clicking
toolStripButton1once:The first button is now up (unchecked) and the second and fourth are down (checked). (I should pay more attention to the consistency in sizing if I do successive images in future posts.)