By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,590 Members | 1,190 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,590 IT Pros & Developers. It's quick & easy.

Tree View

P: n/a
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.

Nov 5 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Nov 5, 7:17*am, "CAM" <alex_marti...@ca.rr.comwrote:
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/libr...openforms.aspx
http://www.experts-exchange.com/Prog..._23751235.html

Hope this helps,

Onur Güzel
Nov 5 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.