Set Menu item checked

  • Thread starter Thread starter Harry Simpson
  • Start date Start date
H

Harry Simpson

I'm trying to programmatically set the Checked property of a menu item to
true. I always get an "internal error" when i try to execute the following
code

Private Sub SetConnectedPic(ByVal isconnected As Boolean)
Try
If isconnected = True Then
MenuItem2.Checked = True
Else
MenuItem2.Checked = False
End If
Catch ex As Exception
End Try
End Sub

Can this be set during runtime? Any ideas?

TIA
Harry
 
It works fine. What is the context of this method, i.e. where do you call it
with that parameters?

1. In a new PPC project, add a MainMenu to a form and a couple of menuitems.
The second menuitem is named MenuItem2. Double clicking on it gives you an
event handler, in there paste the following code:
Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MenuItem2.Click
Me.SetConnectedPic(Not MenuItem2.Checked)
End Sub
2. Also paste in the form your SetConnectedPic function.
3. Run

Does it work?

Cheers
Daniel
 
Back
Top