Click here to Skip to main content
16,020,633 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all,

I have a problem. What is the code for: Let say that I have 2 root and each root have 2 child. Then I want to code by double-click option. This is example of my code:

VB
Private Sub tvlist_DoubleClick
    Select Case tvList.SelectedNode.Name
       Case 0
                If tvList.SelectedNode.Text = "Add Data" Then
                    tvList.SelectedNode.Checked = True
                    Dim memberReg As New System.Windows.Forms.Form
                    memberReg = frmMemberReg
                    memberReg.MdiParent = Me
                    memberReg.Show()
                End If
       Case 1
                If tvList.SelectedNode.Text = "Edit Data" Then
                    tvList.SelectedNode.Checked = True
                    Dim memberReg As New System.Windows.Forms.Form
                    memberReg = frmMemberReg
                    memberReg.MdiParent = Me
                    memberReg.Show()
                End If
    End Select
End Sub


----> Am I wrong with this code? Because I have try the "Select Case tvList.SelectedNode.Index" but I've see the node, some of them have the index 0. I'm afraid that if I call the index 0 from nodes, it will conflict from other index. Could someone help me solve this matter? And how could I code the form by maximize it automatically when it will display?
Posted

1 solution

I'm not sure what you want to do here.
I'm guessing you want to be able to identify what node the user clicked on.
One way to do this is by checking the name from the selectednode as you did in your code.
However if this name isn't unique you will have problems.

Another way is to add a unique identifier to the tag of each node.
I'm assuming you fill the treeviewlist in code, so you can add a unique key into the tag property of each node.
Then you can simply check the tag property of the selectednode and use that to determine what action to take.

As to your second question of how to maximize the form when it displays:

There is a form property windowstate. Set it to maximized. (either in designer or in code)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900