Okay, I'm having issues reading this xml sheet with VB2005.
I was able to populate Combobox1 easily enough with this code.
Now I'm having issues populating a bunch of text boxes and labels on IndexChange. I have created an array of text boxes and labels using "ControlArrayUtils" that I found while digging on the internet. I was able to get a hack of sorts working to populate 1-9 in the labels but it wouldn't change when I would select a different item in the combobox1. The code below is an attempt to get it working but I'm against a wall and I'm tired of beating my head against it
Any help would be greatly appreciated.
Oh and the source code for the controls array can be found at http://www.codeproject.com/vb/net/control_arrays_in_vbnet.asp if its needed.
Thanks again!
VB.NET:
<?xml version="1.0" encoding="utf-8" ?>
<Addressing>
<Type name="US 1">
<Name needs="1">1_ADD</Name>
<Name needs="2">2_ADD</Name>
<Name needs="3">3_ADD</Name>
<Name needs="4">4_ADD</Name>
<Name needs="5">5_DIR</Name>
<Name needs="6">6_TYPE</Name>
<Name needs="7">7_NAM</Name>
<Name needs="8">8_TYPE</Name>
<Name needs="9">9_DIR</Name>
</Type>
<Type name="US One A">
<Name needs="A">A_NUM</Name>
<Name needs="B">B_DIR</Name>
<Name needs="C"></Name>
<Name needs="D">D_NAM</Name>
<Name needs="E">e_TYPE</Name>
<Name needs="F">F_DIR</Name>
</Type>
<Type name="Single Field">
<Name needs="Key Field">KEY</Name>
</Type>
</Addressing>
I was able to populate Combobox1 easily enough with this code.
VB.NET:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' We will start with the make combo box
ComboBox1.Items.Clear()
docXML.Load("fieldmapping.xml")
Dim nodRoot As XmlElement = docXML.DocumentElement
Dim nodItems As XmlNodeList = nodRoot.GetElementsByTagName("Type")
Make combo box
Dim i As Integer
For i = 0 To nodItems.Count - 1 Step 1
ComboBox1.Items.Add(nodItems.ItemOf(i).Attributes.ItemOf("name").InnerText)
Next
End Sub
Now I'm having issues populating a bunch of text boxes and labels on IndexChange. I have created an array of text boxes and labels using "ControlArrayUtils" that I found while digging on the internet. I was able to get a hack of sorts working to populate 1-9 in the labels but it wouldn't change when I would select a different item in the combobox1. The code below is an attempt to get it working but I'm against a wall and I'm tired of beating my head against it
VB.NET:
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
' Get the item that was selected
Dim strAddType As String = Me.ComboBox1.Text()
Dim txtName As TextBox() = CType(ControlArrayUtils.getControlArray(Me, "txtName"), TextBox())
Dim lblName As Label() = CType(ControlArrayUtils.getControlArray(Me, "lblName"), Label())
' Create a list of the nodes we will need to locate
Dim eleRoot As XmlElement = docXML.DocumentElement
Dim nodType As XmlNodeList = eleRoot.GetElementsByTagName("Type")
Dim nodName As XmlNodeList = eleRoot.GetElementsByTagName("Name")
' Dim atrType As XmlAttribute = nodType.ItemOf(i).Attributes("name")
Dim i As Integer
For i = 0 To nodType.Count - 1 Step 1
Try
If (nodType.ItemOf(i).InnerXml = strAddType) Then
Dim atrName As XmlAttribute = nodType.ItemOf(i).Attributes("needs")
Dim strName As String = nodName.ItemOf(i).Attributes.ItemOf("needs").InnerText
MsgBox(strName)
lblName(i).Text = strName
'txtName(i).Text = xmlNL.ItemOf(i).
End If
Catch ex As Exception
System.Diagnostics.Debug.WriteLine(ex.Message)
MsgBox(ex.Message)
End Try
Next
End Sub
Any help would be greatly appreciated.
Oh and the source code for the controls array can be found at http://www.codeproject.com/vb/net/control_arrays_in_vbnet.asp if its needed.
Thanks again!