[Mono-winforms-list] ToolStripMenuItem question

Paul paul at all-the-johnsons.co.uk
Sat Mar 24 17:54:17 EDT 2007


Hi,

I have the following code on a toolstripmenu

private void difficulty_Click(object sender, EventArgs e)
{
  if (sender is ToolStripMenuItem)
  {
     ToolStripMenuItem item = sender as ToolStripMenuItem;
     switch (item.Name)
     {
        case "easy":
          difficulty = 1;
          dtime = 60;
          // item.Checked = true;
          hardness.Text = "Easy";
          break;
        // and so on for medium and hard levels
     }
  }
}

What I'd like to do is add a tick next to the menu item, but if I
uncomment the above commented line, a tick will appear, but then another
will appear if I select another level, but the original remains.

Is there a way to make the menu act as if the ticks are almost like
radio buttons in their operation (one is on, the rest can't be)?

I did think to try something like

(at the start of the winform)

private byte difftick;

then in the routine above.

if (difftick != difficulty)
{
   // untick what difftick was
   // tick the current item
   // set difftick to difficulty
}

Only problem in the ToolStripMenuItem, I can't see a way to do this.

Any help would be appreciated.

TTFN

Paul
-- 
Sie können mich aufreizen und wirklich heiß machen!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.ximian.com/pipermail/mono-winforms-list/attachments/20070324/45a3e02a/attachment.bin 


More information about the Mono-winforms-list mailing list