TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Scott G
NA
103
7.7k
Use treeview node to open another form
Nov 15 2018 1:16 PM
I have a form (form1)with two panels, sidebar and content. I have added a treeview to the sidebar that I want to use to display a different form in content. I have done this before with a button using the following code. I am not sure how to do the same with a treeview node click.
public void nav(Form form, Panel panel)
{
form.TopLevel = false;
form.Size = panel.Size;
panel.Controls.Clear();
panel.Controls.Add(form);
form.Show();
}
private void Button1_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2();
nav(f2, pnlContent);
}
I tried adding the following to my form load and created a NodeMouseClick event but nothing happened.
treeView1.NodeMouseClick +=
new TreeNodeMouseClickEventHandler(treeView1_NodeMouseClick);
void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
if (e.Node.Name == "Form2")
{
Form2 f2 = new Form2();
nav(f2, pnlContent);
}
}
Suggestions are greatly appreciated.
Reply
Answers (
0
)
SQL Script to get latest record posted BY ID
difference between using .NET Core and .NET Framework