Home All Groups Group Topic Archive Search About
Author
3 Mar 2006 12:34 AM
Pascal
I can't find the equivalent of the old MenuItem.RadioCheck property on

ToolStripMenuItem.

I need to allow the menu to have a subgroup of mutually exclusive choices.

How am I supposed to do this now in 2.0?
thanks for help

http://www.scalpa.info

Author
3 Mar 2006 1:41 AM
Homer J Simpson
"Pascal" <scalpano***@wanadoo.rf> wrote in message
news:44078ef3$0$6644$8fcfb975@news.wanadoo.fr...

>I can't find the equivalent of the old MenuItem.RadioCheck property on
>
> ToolStripMenuItem.
>
> I need to allow the menu to have a subgroup of mutually exclusive choices.
>
> How am I supposed to do this now in 2.0?
> thanks for help

Use checkboxes instead and write code to uncheck the other choices.
Author
3 Mar 2006 2:32 AM
CMM
Not so fast there... if the items are mutually exclusive, that's bad UI
design and bad advice. Windows Official Guidelines for UI Design:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwue/html/ch08b.asp
Read the section towards the end titled "Types of Menu Items"

Here's an easy way to get the ToolStripMenuItem to do what the dolts at MS
were too busy playing ping pong to forget to do.
http://blogs.msdn.com/jfoscoding/archive/2006/02/07/526335.aspx


--
-C. Moya
www.cmoya.com

"Homer J Simpson" <nob***@nowhere.com> wrote in message
news:O8NNf.10802$vC4.602@clgrps12...
Show quoteHide quote
>
> "Pascal" <scalpano***@wanadoo.rf> wrote in message
> news:44078ef3$0$6644$8fcfb975@news.wanadoo.fr...
>
>>I can't find the equivalent of the old MenuItem.RadioCheck property on
>>
>> ToolStripMenuItem.
>>
>> I need to allow the menu to have a subgroup of mutually exclusive
>> choices.
>>
>> How am I supposed to do this now in 2.0?
>> thanks for help
>
> Use checkboxes instead and write code to uncheck the other choices.
>
>
>
Author
3 Mar 2006 10:53 AM
Pascal
oops it seems too hard to understand and use for me.... arrrgh It is a pity!
#########################################################
menuStrip1.Renderer = new RadioCheckRenderer();


   public class RadioCheckRenderer : ToolStripProfessionalRenderer {

        protected override void
OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) {

            RadioButtonRenderer.DrawRadioButton(e.Graphics,
e.ImageRectangle.Location,
System.Windows.Forms.VisualStyles.RadioButtonState.CheckedNormal);

        }

    }

########################################################
what's the way to use this part of code ?  Mystery...

thanks Thank you nevertheless.
Author
3 Mar 2006 1:43 PM
CMM
Create this class:
Public Class MyCustomToolStripProfessionalRenderer
    Inherits ToolStripProfessionalRenderer

    Protected Overrides Sub OnRenderItemCheck(ByVal e As
System.Windows.Forms.ToolStripItemImageRenderEventArgs)
        Dim stringFormat As New StringFormat
        stringFormat.Alignment = StringAlignment.Center
        e.Graphics.DrawString("i", New Font("Marlett", 12, FontStyle.Bold),
SystemBrushes.MenuText, e.ImageRectangle, stringFormat)

        'or you can use this instead for an interesting look
        'RadioButtonRenderer.DrawRadioButton(e.Graphics,
e.ImageRectangle.Location,
System.Windows.Forms.VisualStyles.RadioButtonState.CheckedNormal)
    End Sub
End Class

In your Form_Load, do this:
Me.MenuStrip1.Renderer = New MyCustomToolStripProfessionalRenderer


--
-C. Moya
www.cmoya.com
Show quoteHide quote
"Pascal" <scalpano***@wanadoo.rf> wrote in message
news:44081ffd$0$18320$8fcfb975@news.wanadoo.fr...
> oops it seems too hard to understand and use for me.... arrrgh It is a
> pity!
> #########################################################
> menuStrip1.Renderer = new RadioCheckRenderer();
>
>
>   public class RadioCheckRenderer : ToolStripProfessionalRenderer {
>
>        protected override void
> OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) {
>
>            RadioButtonRenderer.DrawRadioButton(e.Graphics,
> e.ImageRectangle.Location,
> System.Windows.Forms.VisualStyles.RadioButtonState.CheckedNormal);
>
>        }
>
>    }
>
> ########################################################
> what's the way to use this part of code ?  Mystery...
>
> thanks Thank you nevertheless.
>
Author
3 Mar 2006 7:41 PM
Pascal
Arrghglglgl.... I did the job (well explain for me thanks); no errors when i
debug but nothing appears on the dropdown menu when the form load. Radio
button appear only when i click.
So i change my mind and :
from microsoft here is the code :
Private Sub MenuOption_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)

For Each item As Object In MonMenuToolStripMenuItem.DropDownItems

If (TypeOf item Is ToolStripMenuItem) Then

Dim itemObject As ToolStripMenuItem = CType(item, ToolStripMenuItem)

itemObject.Checked = False

End If

Next

Dim selectedItem As ToolStripMenuItem = CType(sender, ToolStripMenuItem)

selectedItem.Checked = True

End Sub



like this it works fine...
Author
3 Mar 2006 8:54 PM
Homer J Simpson
"Pascal" <scalpano***@wanadoo.rf> wrote in message
news:44089b8b$0$21297$8fcfb975@news.wanadoo.fr...

> Arrghglglgl.... I did the job (well explain for me thanks); no errors when
> i debug but nothing appears on the dropdown menu when the form load. Radio
> button appear only when i click.

Yes. Using this stuff is like trying to knit wet spaghetti.