[Mono-winforms-list] ToolStripMenuItem question

Jonathan Pobst monkey at jpobst.com
Sat Mar 24 18:29:37 EDT 2007


MSDN has an example here: 
http://msdn2.microsoft.com/en-us/library/ms404318.aspx

It also does custom painting to make it look like a radio button, but 
you can ignore that part if you are happy with the check marks.

Jon


Paul wrote:
> 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
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Mono-winforms-list maillist  -  Mono-winforms-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-winforms-list



More information about the Mono-winforms-list mailing list