We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Show form when node is clicked vb.net


Hi

Could someone advise me on how to open a windows form when a child is clicked, i've been trying to work it out without success.

Thanks


2 Replies

TH Toby Hutton June 16, 2015 07:37 PM UTC


Just sorted it, Re-tweaked a bit of code. For those that a interested be see below, I have included both C# and VB

VB

Private Sub TreeView1_AfterSelect(ByVal sender As Object, ByVal e As EventArgs) Handles TreeView1.AfterSelect
        Dim tn As TreeNodeAdv = Me.TreeView1.SelectedNode
        Select Case tn.Text
            Case "About"
                AboutForm.Show()
            Case Else
                MessageBox.Show("This node does not have a form associated with it.")
        End Select
    End Sub

C#

private void TreeView1_AfterSelect(object sender, EventArgs e)
{
	TreeNodeAdv tn = this.TreeView1.SelectedNode;
	switch (tn.Text) {
		case "About":
			AboutForm.Show();
			break;
		default:
			MessageBox.Show("This node does not have a form associated with it.");
			break;
	}
}


AJ Ashwini Jaya Preetha Durai Samy Syncfusion Team June 17, 2015 08:25 AM UTC

Hi Toby,

Thank you for using Syncfusion products.

We are glad to hear that your requirement has been achieved. It can also be done by using the NodeMouseClick event as in the below code snippet.

Code snippet[ C#]:


  // Loading Form using NodesMouseClick event

        void treeViewAdv1_NodeMouseClick(object sender, Syncfusion.Windows.Forms.Tools.TreeViewAdvMouseClickEventArgs e)

        {

            Form2 form2 = new Form2();      

            if(e.Node.Text=="ChildNode")

                form2.Show();
        }


Code snippet [VB]:


' Loading Form using NodesMouseClick event

              Private Sub treeViewAdv1_NodeMouseClick(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Tools.TreeViewAdvMouseClickEventArgs)

                     Dim form2 As New Form2()

                     If e.Node.Text="ChildNode" Then

                           form2.Show()

                     End If
              End Sub


Sample Location: http://www.syncfusion.com/downloads/support/forum/119402/ze/TreeViewAdvFormLoadSample1324049284

Please let us know if you need any further assistance,

Regards,
Ashwini

Loader.
Live Chat Icon For mobile
Up arrow icon