Select / Deselect Menu Items

  • Thread starter Thread starter Steven Smith
  • Start date Start date
S

Steven Smith

This piece of code handles the selection & deselection of
main menu items and serves this purpose well although I'm
not convinced this is the most effective way to do it as
it seems a bit long winded. Perhaps theres a quicker,
easier & shorter method to code this. any suggestions
would be appreciated as always

///
Private Sub DisplayRocketMenuItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) _
Handles DisplayRocketMenuItem.Click

Static tRocketHideShow As Boolean

tRocketHideShow = Not tRocketHideShow

If tRocketHideShow = True Then
Me.DisplayRocketMenuItem.Checked = True
Me.IdRocketLabel.Visible = True
Me.RocketPictureBox.Visible = True
Else
Me.DisplayRocketMenuItem.Checked = False
Me.IdRocketLabel.Visible = False
Me.RocketPictureBox.Visible = False
End If


End Sub

Private Sub DisplayCarsMenuItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) _
Handles DisplayCarsMenuItem.Click

Static tCarsHideShow As Boolean

tCarsHideShow = Not tCarsHideShow

If tCarsHideShow = True Then
Me.DisplayCarsMenuItem.Checked = True
Me.IdCarsLabel.Visible = True
Me.CarsPictureBox.Visible = True
Else
Me.DisplayCarsMenuItem.Checked = False
Me.IdCarsLabel.Visible = False
Me.CarsPictureBox.Visible = False
End If


End Sub
///


Regards Steve...
 
-----Original Message-----
Hi Steve,
I did some changes, I do not know if you mean this.
To answer your question about faster.
You can use a container or a group box.
The fastest way to use that: Just drag them on your form and then drag the
controls in it.

"> Private Sub DisplayRocketMenuItem_Click(ByVal sender As
Dim tRocketHideShow As Boolean
tRocketHideShow = Not
me.IdRocketLabel.Visible 'Just for the example
Me.DisplayRocketMenuItem.Checked = tRocketHideShow
Me.IdRocketLabel.Visible = tRocketHideShow
Me.RocketPictureBox.Visible = tRocketHideShow
End Sub

Regards,
Cor


Hi Cor, thanks for that, I never really worded my
original post very well, I was just looking for anyway to
optimise code and your solution appears to do this...

Thanks & Regards Steve
 
Back
Top