C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




How to add node in treeview in VB.NET


Posted Date: 30 Aug 2008      Total Responses: 2

Posted By: kali raj       Member Level: Gold     Points: 1


How to add node in treeview in VB.NET



Responses

Author: Pradeep Kumar Chaudhary    30 Aug 2008Member Level: GoldRating:     Points: 6
Dim N As TreeNode

'Method 1: straightforward adding of nodes
With Me.TreeView1.Nodes
'add text
.Add("AddByText")
'since with..end with is used: read TreeView1.Nodes.Add ....

'every add method returns the newly created node. You can use
'this concept set the result to a variable or to directly add
'a childnode:
.Add("AddByText2").Nodes.Add("ChildOfAddByText")

'this, you can take as far as you want
.Add("AddByText3").Nodes.Add("ChildOfAddByText").Nodes.Add("Another child")

'--
N = .Add("AddByText, Attach To Variable")
N.Nodes.Add("Child one")
N.Nodes.Add("Child two")
' --
With .Add("AddByText Use WithTo Add ChildNodes").Nodes
.Add("Child 1")
.Add("Child 2")
.Add("Child 3").Nodes.Add("Subchild 1")
End With
End With



Author: UltimateRengan    01 Sep 2008Member Level: DiamondRating:     Points: 6
hi,
Take this example

Imports System.Data
Imports System.Data.SqlClient
Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
BindData()
End If

End Sub
Sub BindData()
Dim strConn As String
strConn = "USER=asdf;PASSWORD=iiii;SERVER=jjj;DATABASE=Emp"
Dim MySQL As String = "Select x,empno, jj from x"
Dim MyConn As New SqlClient.SqlConnection(strConn)
Dim ds As DataSet = New DataSet()
Dim Cmd As New SqlClient.SqlDataAdapter(MySQL, MyConn)
Cmd.Fill(ds, "Emptbl")
'Fill the TreeView control Nodes using For Loop
For Each Row As DataRow In ds.Tables("Emptbl").Rows
Dim TNode As New TreeNode("First")
TreeView1.Nodes.Add(TNode)
Dim CNode1 As New TreeNode(Row("x"))
TNode.ChildNodes.Add(CNode1)
Dim CNode2 As New TreeNode(Row("empno"))
TNode.ChildNodes.Add(CNode2)
Dim CNode3 As New TreeNode(Row("jj"))
TNode.ChildNodes.Add(CNode3)
TNode.CollapseAll()
Next
End Sub
End Class






Post Reply
You must Sign In to post a response.
Next : How to use Progress bar ?
Previous : Killing a particular excel process using procedd id
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

web conferencing

Contact Us    Privacy Policy    Terms Of Use