ManicCW
Well-known member
Hi I need to load this (these numbers are just example it will be some text):
from XML file into GridView which has 2 Columns. I need it to look like this:
http://www.vbdotnetforums.com/attachment.php?attachmentid=666&stc=1&d=1150098278
This is the code where I need this:
Here is how I write it in XML:
VB.NET:
<Dijelovi>
<Zamjena>1;3;5;7</Zamjena>
<Popravka>2;4;6</Popravka>
</Dijelovi>
http://www.vbdotnetforums.com/attachment.php?attachmentid=666&stc=1&d=1150098278
This is the code where I need this:
VB.NET:
'get data in controls
For Each ctr As Control In doc.Controls
If TypeOf ctr Is TextBox Then
CType(ctr, TextBox).Text = xdoc.GetElementsByTagName(ctr.Name.Remove(0, 3)).Item(0).InnerText
ElseIf TypeOf ctr Is DateTimePicker Then
CType(ctr, DateTimePicker).Value = CDate(xdoc.GetElementsByTagName(ctr.Name.Remove(0, 3)).Item(0).InnerText)
ElseIf TypeOf ctr Is CheckBox Then
CType(ctr, CheckBox).Checked = CBool(xdoc.GetElementsByTagName(ctr.Name.Remove(0, 3)).Item(0).InnerText)
ElseIf TypeOf ctr Is ComboBox Then
CType(ctr, ComboBox).SelectedValue = xdoc.GetElementsByTagName(ctr.Name.Remove(0, 3)).Item(0).InnerText
ElseIf TypeOf ctr Is RadioButton Then
CType(ctr, RadioButton).Checked = CBool(xdoc.GetElementsByTagName(ctr.Name.Remove(0, 3)).Item(0).InnerText)
ElseIf TypeOf ctr Is DataGridView Then
[B]?????????[/B]
End If
Next
VB.NET:
...
ElseIf TypeOf ctr Is DataGridView Then
Dim row As DataGridViewRow
Dim col As DataGridViewColumn
xnode = xdoc.CreateElement(ctr.Name.Remove(0, 3))
xdoc.DocumentElement.AppendChild(xnode)
Dim catNode As XmlNode
For Each col In CType(ctr, DataGridView).Columns
catNode = xdoc.CreateElement(col.Name)
For Each row In CType(ctr, DataGridView).Rows
If IsNothing(row.Cells(col.Index).Value) = False Then
catNode.InnerText &= row.Cells(col.Index).Value & ";"
End If
Next
catNode.InnerText = catNode.InnerText.Remove(catNode.InnerText.LastIndexOf(";"), 1)
xnode.AppendChild(catNode)
Next
End If