Click here to Skip to main content
15,908,843 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: repeater Pin
J4amieC30-Mar-06 3:23
J4amieC30-Mar-06 3:23 
Questioncombo box Pin
cupid_nex29-Mar-06 16:10
cupid_nex29-Mar-06 16:10 
AnswerRe: combo box Pin
Christian Graus29-Mar-06 17:24
protectorChristian Graus29-Mar-06 17:24 
AnswerRe: combo box Pin
jcrussell2-Apr-06 19:18
jcrussell2-Apr-06 19:18 
Questionsend email from localhost to webmail Pin
besah29-Mar-06 15:57
besah29-Mar-06 15:57 
AnswerRe: send email from localhost to webmail Pin
prokleta_nedelja29-Mar-06 18:28
prokleta_nedelja29-Mar-06 18:28 
GeneralRe: send email from localhost to webmail Pin
Swammingo30-Mar-06 0:24
Swammingo30-Mar-06 0:24 
QuestionTree View of XML Data Pin
u1119029-Mar-06 14:33
u1119029-Mar-06 14:33 
I am working on a program for VS.net that reads data from XML file and list them in treeview. The XML file named Dooa. Elements under Dooa are F1, F2, and F3. F1 is the root (parent) and F2 is the child and the content of F3 will be displayed in TEXTBOX1 if F1 or F2 selected. See the code.

What I want is that, if F1 are same for some roots then F2 (child(s)) for these roots should be listed under F1. Example


This is the XML

<dataroot NS0:noNamespaceSchemaLocation="Dooa.xsd" generated="2005-11-01T15:40:12" xmlns:NS0="Dooa">

<Dooa>
<F1>First</F1>
<F2>Car1</F2>
<F3>Home1</F3>
</Dooa>
<Dooa>
<F1>First</F1>
<F2>Car2</F2>
<F3>Home2</F3>
</Dooa>
<Dooa>
<F1>Second</F1>
<F2>CarA</F2>
<F3>HomeA</F3>
</Dooa>
<Dooa>
<F1>Second</F1>
<F2>CarB</F2>
<F3>HomeB</F3>
</Dooa>

</dataroot>


Then treeview should be like this

First
Car1
Car2
Second
CarA
CarB

What is the missing code that should take care of what I need as explained above??



Here is the code

Imports System.IO
Imports System.Xml
______________________________________________________________________

Public Class Form1
Inherits System.Windows.Forms.Form
Private Const dataXML As String = "c:\Data1.xml"
Private dsData As System.Data.DataSet
______________________________________________________________________

Private Sub loadData()
dsData = New DataSet("Data")
Dim fs As New FileStream(dataXML, FileMode.Open)
Dim xr As New XmlTextReader(fs)
dsData.ReadXml(xr)
End Sub
______________________________________________________________________

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
loadData()

Dim dr As DataRow
For Each dr In dsData.Tables("Dooa").Rows
TreeView1.Nodes.Add(dr("F1").ToString()).Nodes.Add(dr("F2").ToString())
Next
End Sub
_______________________________________________________________________

Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect

Dim dr As DataRow
For Each dr In dsData.Tables("Dooa").Rows
If dr("F2").ToString() = TreeView1.SelectedNode.Text.ToString() Then
TextBox1.Text = dr("F3").ToString()
TextBox3.Text = dr("F2").ToString()
End If
Next
End Sub
_____________________________________________________________

Private Sub MenuItem2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click
TreeView1.BackColor = Color.FromArgb(212, 199, 130)
TreeView1.Visible = True
End Sub





-- modified at 20:36 Wednesday 29th March, 2006
GeneralAnswer - how to stop running when form close Pin
Chatura Dilan29-Mar-06 13:54
Chatura Dilan29-Mar-06 13:54 
QuestionLinking two programs Pin
Khomeini29-Mar-06 12:58
Khomeini29-Mar-06 12:58 
AnswerRe: Linking two programs Pin
jcrussell29-Mar-06 15:24
jcrussell29-Mar-06 15:24 
QuestionLinking two programs Pin
Khomeini29-Mar-06 12:21
Khomeini29-Mar-06 12:21 
AnswerRe: Linking two programs Pin
Steve Pullan29-Mar-06 12:47
Steve Pullan29-Mar-06 12:47 
QuestionArguments "%1" and other... Not urgent :) Pin
FeRtoll29-Mar-06 10:13
FeRtoll29-Mar-06 10:13 
AnswerRe: Arguments &quot;%1&quot; and other... Not urgent :) Pin
Joshua Quick29-Mar-06 15:03
Joshua Quick29-Mar-06 15:03 
GeneralRe: Arguments "%1" and other... Not urgent :) Pin
FeRtoll29-Mar-06 22:44
FeRtoll29-Mar-06 22:44 
GeneralRe: Arguments "%1" and other... Not urgent :) Pin
Steve Pullan30-Mar-06 11:53
Steve Pullan30-Mar-06 11:53 
GeneralRe: Arguments "%1" and other... Not urgent :) Pin
FeRtoll29-Mar-06 22:53
FeRtoll29-Mar-06 22:53 
GeneralRe: Arguments "%1" and other... Not urgent :) Pin
J4amieC29-Mar-06 23:02
J4amieC29-Mar-06 23:02 
AnswerRe: Arguments "%1" and other... Not urgent :) Pin
Joshua Quick30-Mar-06 11:26
Joshua Quick30-Mar-06 11:26 
GeneralRe: Arguments "%1" and other... Not urgent :) Pin
FeRtoll7-Feb-07 9:44
FeRtoll7-Feb-07 9:44 
QuestionVBS, piping out the results to text Pin
aste629-Mar-06 8:02
aste629-Mar-06 8:02 
QuestionCombo Box Pin
rahsi29-Mar-06 7:17
rahsi29-Mar-06 7:17 
AnswerRe: Combo Box Pin
Steve Pullan29-Mar-06 12:58
Steve Pullan29-Mar-06 12:58 
GeneralRe: Combo Box Pin
rahsi30-Mar-06 4:54
rahsi30-Mar-06 4:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.