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!
:thumb:
Printable View
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!
:thumb:
Anybody?
that's noteme's :bigyello:
:bigyello: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
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!
You could just turn on allowedit after checking what the selected item is. If the item is invalid, turn it off.
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!