|
-
Aug 24th, 2004, 10:06 AM
#1
Thread Starter
Registered User
Editing Treeview's node text [Solved]
Setting a treeview's LabelEdit property to True, enable the user to edit a node's text.
Is there any way to set this property on a node level? Cuz I want to let the user be able to edit some nodes, other not.
Cheers!
Last edited by NicoNel2000; Aug 25th, 2004 at 07:33 AM.
-
Aug 25th, 2004, 01:40 AM
#2
Thread Starter
Registered User
-
Aug 25th, 2004, 02:12 AM
#3
Fanatic Member
that's noteme's
VB Code:
Dim cn As New SqlConnection("user id=sa;password=password;initial catalog=northwind")
Dim da As New SqlDataAdapter()
Dim dt As New DataTable()
WithEvents t As New TextBox()
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
da.SelectCommand = New SqlCommand("select * from territories", cn)
da.Fill(dt)
Dim r As DataRow
Dim i As Integer = 0
For Each r In dt.Rows
TreeView1.Nodes.Add(r(0).ToString)
Dim j As Integer
For j = 1 To dt.Columns.Count - 1
TreeView1.Nodes(i).Nodes.Add(r(j).ToString)
Next
i += 1
Next
TreeView1.Controls.Add(t)
t.Hide()
End Sub
Private Sub TreeView1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles TreeView1.DoubleClick
tn = TreeView1.SelectedNode
t.Location = p
t.Show()
t.Text = tn.Text
End Sub
Dim p As Point
Dim tn As TreeNode
Private Sub TreeView1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TreeView1.MouseDown
p = New Point(e.X, e.Y)
End Sub
Private Sub t_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles t.Leave
t.Hide()
tn.Text = t.Text
End Sub
-
Aug 25th, 2004, 02:16 AM
#4
Thread Starter
Registered User
Had a quick look,
So you do away with the labeledit, and actually put a textbox on the node if you want the user to edit it?
will rip it apart just now.....in middle of some dragging and dropping stuff right now..pretty cool!
-
Aug 25th, 2004, 06:10 AM
#5
You could just turn on allowedit after checking what the selected item is. If the item is invalid, turn it off.
-
Aug 25th, 2004, 07:33 AM
#6
Thread Starter
Registered User
Sorry mate, that's exactly what I thought of afterwards, and did not have the presence of mind to edit my post to solved.
Thanx for the reply though!
Cheers!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|