Tree View

C

CAM

Hello,

I am using Visual Basic.Net 2008 and in my main menu form I have a tree view
in one of the child node I have a code that opens another form.

Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect

If e.Node.Name = "NodeUnassigned" Then

frmUnassigned.Show()

ElseIf e.Node.Name = "NodeDailyReports" Then

frmDailyReports.Show()
End If

Now the form "NodeUnassigned" and "NodeDailyReports" when pressed does show
the form, but soon as the form opens the "Main Menu" form appears I really
want to close the Main Menu form. How can I stop the "Main Menu" open up
again I just want to open the other form and close the Main Menu form? Does
anybody knows the code? Thank you in advance.
 
K

kimiraikkonen

Hello,

I am using Visual Basic.Net 2008 and in my main menu form I have a tree view
in one of the child node I have a code that opens another form.

Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect

        If e.Node.Name = "NodeUnassigned" Then

            frmUnassigned.Show()

        ElseIf e.Node.Name = "NodeDailyReports" Then

            frmDailyReports.Show()
        End If

Now the form "NodeUnassigned" and "NodeDailyReports" when pressed does show
the form, but soon as the form opens the "Main Menu" form appears I really
want to close the Main Menu form.  How can I stop the "Main Menu" open up
again I just want to open the other form and close the Main Menu form?  Does
anybody knows the code?  Thank you in advance.

You didn't include why and how you open "Main Menu" form, however as
you want to close Main Menu form when it's opened, so you can loop
through OpenForms property to determine when the form is opened, then
use Close() method to close it.

Again, it's not apparent when and where you want to close it from,
then use it carefully when you really need to close form because you
may need it at any time, so another choice would be Hide() method in
some cases.

http://msdn.microsoft.com/en-us/library/system.windows.forms.application.openforms.aspx
http://www.experts-exchange.com/Programming/Languages/.NET/Q_23751235.html

Hope this helps,

Onur Güzel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top