Link to home
Start Free TrialLog in
Avatar of cee1891
cee1891

asked on

How can i contorl the menu in vb.net

Hei

I can't handle da menu in da way dat if once the menu is been clicked the form will appear and  other time if da same menu is been clicked it shouldn't appear again dat same form or in other words shouldn't make n new instance ..

one way was of disabling n other of making it visible = false ... but ain't working ...
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Here is a simple example of a Button on Form1 that makes only one instance of Form2 appear.  If Form2 is minimized then it is restored.

Public Class Form1
    Inherits System.Windows.Forms.Form

    Private WithEvents f2 As Form2

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If f2 Is Nothing Then
            f2 = New Form2
            f2.Show()
        Else
            If f2.WindowState = FormWindowState.Minimized Then
                f2.WindowState = FormWindowState.Normal
            End If
            f2.Focus()
        End If
    End Sub

    Private Sub f2_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles f2.Closed
        f2 = Nothing
    End Sub

End Class
ASKER CERTIFIED SOLUTION
Avatar of wguerram
wguerram

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial