Results 1 to 6 of 6

Thread: Editing Treeview's node text [Solved]

  1. #1

    Thread Starter
    Registered User NicoNel2000's Avatar
    Join Date
    Feb 2004
    Location
    Beijing - China
    Posts
    296

    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.

  2. #2

    Thread Starter
    Registered User NicoNel2000's Avatar
    Join Date
    Feb 2004
    Location
    Beijing - China
    Posts
    296
    Anybody?

  3. #3
    Fanatic Member brown monkey's Avatar
    Join Date
    Jun 2004
    Location
    Cebu
    Posts
    552
    that's noteme's

    VB Code:
    1. Dim cn As New SqlConnection("user id=sa;password=password;initial catalog=northwind")
    2.    Dim da As New SqlDataAdapter()
    3.    Dim dt As New DataTable()
    4.    WithEvents t As New TextBox()
    5.    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    6.       da.SelectCommand = New SqlCommand("select * from territories", cn)
    7.       da.Fill(dt)
    8.       Dim r As DataRow
    9.       Dim i As Integer = 0
    10.       For Each r In dt.Rows
    11.          TreeView1.Nodes.Add(r(0).ToString)
    12.          Dim j As Integer
    13.          For j = 1 To dt.Columns.Count - 1
    14.             TreeView1.Nodes(i).Nodes.Add(r(j).ToString)
    15.          Next
    16.          i += 1
    17.       Next
    18.       TreeView1.Controls.Add(t)
    19.       t.Hide()
    20.    End Sub
    21.  
    22.    Private Sub TreeView1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles TreeView1.DoubleClick
    23.       tn = TreeView1.SelectedNode
    24.       t.Location = p
    25.       t.Show()
    26.       t.Text = tn.Text
    27.    End Sub
    28.  
    29.    Dim p As Point
    30.    Dim tn As TreeNode
    31.    Private Sub TreeView1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TreeView1.MouseDown
    32.       p = New Point(e.X, e.Y)
    33.    End Sub
    34.  
    35.    Private Sub t_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles t.Leave
    36.       t.Hide()
    37.       tn.Text = t.Text
    38.    End Sub

  4. #4

    Thread Starter
    Registered User NicoNel2000's Avatar
    Join Date
    Feb 2004
    Location
    Beijing - China
    Posts
    296
    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!

  5. #5
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780
    You could just turn on allowedit after checking what the selected item is. If the item is invalid, turn it off.

  6. #6

    Thread Starter
    Registered User NicoNel2000's Avatar
    Join Date
    Feb 2004
    Location
    Beijing - China
    Posts
    296
    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
  •  



Click Here to Expand Forum to Full Width