Jump to content
  • Advertisement
Sign in to follow this  
myvraccount

Toggling buttons on a toolstrip

This topic is 931 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This is ridiculous!  All I'm trying to do is select and deselect a toolstrip button when I click it, the same way the "Left Align" button I'm looking at right now is selected in this text editor.

 

So I try to call select on the button, but nothing happens.  I found out the hard way that it's because the canSelect property is false, but it's read only, because it's calculated from other things (like whether it's visible etc.).

 

So I looked up what would make it true, so if I change that manually, then when I call select, it should work right?

 

Well the main thing is that there's an enumeration type called ControlStyle, which has a flag in it called Selectable.  This enumeration is supposed to be hidden somewhere in Control, and it can only be changed by calling SetStyle(ControlStyle, bool) - so I guess I set one bool at a time to true or false.

 

I couldn't find it, but I managed to find it in a different project on a different computer in a different version of .NET (yay for potential incompatibilities!  I think the other one it using VS2010 or something, maybe 2012).

 

Anyway, I only found it in Form, but I still can't find it in ToolStrip or ToolStripButton.  Don't they inherit Control?  And if not, how can I actually make them selectable, and WHY aren't they by DEFAULT?!?!

 

Also, I'd like to be able to select and deselect them independently so I can select multiple simultaneously so I can have image buttons that act like checkboxes.

 

I've spent a few hours on something that should have taken a few SECONDS and now I'm really aggravated!  Please tell me how to do this.

 

Thanks.

Share this post


Link to post
Share on other sites
Advertisement

It's the stupidest thing!  It turned out that I needed the CHECKED property, not the SELECTED property!!!  why would anyone call it CHECKED if there's not actually a check mark?!?!?!  This is maddening!!!  What does selected even do then?  How is highlighting it when I click it not the same as selecting it?!

Share this post


Link to post
Share on other sites

Under the hood they are secretly check boxes.  The status of the checkbox indicates if the image should be popped in or popped out, or grayed out.

 

Selected generally refers to the cursor. 

Share this post


Link to post
Share on other sites

Well that makes sense, but I wish they'd implement it in a more intuitive way.  I almost never would have figured that out, and I was on the wrong track for the better part of a day!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!