472,126 Members | 1,550 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,126 software developers and data experts.

MenuStrip in Windows Form (C#)

Atran
319 100+
Hello:
I have a MenuStrip in my form, so I add a ToolStripMenuItem to the MenuStrip.
The ToolStripMenuItem has a checkBox.
-------------------------------------------------------------
Now, The ToolStripMenuItem is checked.
I want: When I click The ToolStripMenuItem, The ToolStripMenuItem be unchecked, and when I back again and click The ToolStripMenuItem, The ToolStripMenuItem be checked.
I try this code, but doesnt work:
Expand|Select|Wrap|Line Numbers
  1. private void ToolStripMenuItem_Click(object sender, EventArgs e)
  2.         {
  3.             if (ToolStripMenuItem.Checked.Equals(true) == true)
  4.             {
  5.                 ToolStripMenuItem.Checked.Equals(false);
  6.             }
  7.             if (ToolStripMenuItem.Checked.Equals(false) == true)
  8.             {
  9.                 ToolStripMenuItem.Checked.Equals(true);
  10.             }
  11.         }
  12.  
Thanks................
Jun 12 '07 #1
3 8442
Plater
7,872 Expert 4TB
There is a property you can set to have this done automatically CheckOnClick
Jun 12 '07 #2
TRScheel
638 Expert 512MB
On an aside, couldnt you just write:

Expand|Select|Wrap|Line Numbers
  1. ToolStripMenuItem.Checked = !ToolStripMenuItem.Checked;
Jun 12 '07 #3
Atran
319 100+
Thanks to you all................
Jun 12 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by John J. Hughes II | last post: by
reply views Thread by genojoe | last post: by
1 post views Thread by genojoe | last post: by
1 post views Thread by Schwammkopf | last post: by
3 posts views Thread by Gav | last post: by
1 post views Thread by Tony Johansson | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.