How to Populate tree view object ???

  • Thread starter Thread starter serge calderara
  • Start date Start date
S

serge calderara

Dear all,

I have the configuration part of my application which will
handle different element configuartion based on tree view
object similar as MMC and snap in.

Configuration data are retrive and save in a local
database for each component.

What is the best way to populate my tree view control.
Is there a easy way to map them to a dataset or XML file?

what is the best and simple.

thnaks for your reply
serge
 
I'm doing it from a dataset, loading the XML file first.
(called DsEdit in this code snippet).
LcFilename as the name of an XML file.

'''''''''''''''''''''''''''''''''''''''''''''''''''''''

' Create a FileStream object with the file path
and name.
Dim myFileStream As New System.IO.FileStream
(lcFilename, System.IO.FileMode.Open)
' Create a new XmlTextReader object with the
FileStream.
Dim myXmlTextReader As New System.Xml.XmlTextReader
(myFileStream)
' Read the data into the DataSet and close the
reader.
DsEdit.ReadXml(myXmlTextReader)
myXmlTextReader.Close()

TreeView1.Nodes.Clear()
Dim t As DataTable
Dim r As DataRow
Dim c As DataColumn
For Each t In DsEdit.Tables
Dim Tablenode As New TreeNode(t.TableName)
TreeView1.Nodes.Add(Tablenode)
Tablenode.ImageIndex = 0
Tablenode.SelectedImageIndex = 1
Dim FieldNode As TreeNode
For Each c In t.Columns
FieldNode = Tablenode.Nodes.Add
(c.ColumnName)
FieldNode.ImageIndex = 2
FieldNode.SelectedImageIndex = 2
FieldNode.Tag = Tablenode.Text
Next
Next
c = Nothing
r = Nothing
t = Nothing

'''''''''''''''''''''''''''''''''
Good luck
Moose
 
Back
Top