|
-
Oct 29th, 2008, 01:53 PM
#1
Thread Starter
New Member
-
Oct 29th, 2008, 06:53 PM
#2
Re: Can I output tree view nodes text in listbox?
You should create a collection of TreeNodes and bind that to your ListBox. You can then add and remove nodes from that collection at will and the ListBox will update, IF you've done it properly.
vb.net Code:
Imports System.ComponentModel Public Class Form1 Private nodes As New BindingList(Of TreeNode) Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Bind the collection to the ListBox, displaying the Text property of each item. Me.ListBox1.DisplayMember = "Text" Me.ListBox1.DataSource = Me.nodes End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If Not Me.nodes.Contains(Me.TreeView1.SelectedNode) Then 'Add the selected node to the collection. Me.nodes.Add(Me.TreeView1.SelectedNode) 'Refresh the bound control. Me.nodes.ResetBindings() End If End Sub End Class
-
Oct 30th, 2008, 11:25 AM
#3
Thread Starter
New Member
Re: Can I output tree view nodes text in listbox?
thank you so much! it seems to be working.
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
|