MenuItem.RadioCheck

  • Thread starter Thread starter Pascal
  • Start date Start date
P

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
 
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.
 
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.
 
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
 
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...
 
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.
 
Back
Top