TextBox.Text to XML file
I have a form with nearly 100 textboxes on it!. I know this seems like too many but there it is. The problem I have is, after text has been placed in the textboxes, I need a way to save this data to an XML file or something simpler if possible. I have tried to do this before and I may have succeeded but I can't remember what I did (old-timer's disease). If anyone can offer a suggestion for a decent primer in this particular area I would be grateful. Please do not direct me to the MSDN files as I don't understand half f what they are saying. My grounding in VB is a little shaky having largely been acquired "on the fly".
VulpesPosted Oct 24, 2012, 1:46 PM
The code to repopulate the textboxes from the file would be:
DuanePosted Oct 24, 2012, 11:43 PM
DuanePosted Oct 24, 2012, 12:36 PM
If so, thats not a problem, its getting to the individual nodes afterward thats the problem.
DuanePosted Oct 24, 2012, 12:20 AM
VulpesPosted Oct 23, 2012, 1:38 PM
Dim root As New XElement("TextBoxes")
For Each ctrl As Control In Me.Controls
If TypeOf (ctrl) Is Panel Then
Dim pnl As XElement = New XElement(ctrl.Name)
For Each c As Control In ctrl.Controls
If TypeOf (c) Is TextBox Then
pnl.Add(New XElement(c.Name, c.Text))
End If
Next
root.Add(pnl)
End If
Next
root.Save("textboxes.xml")
DuanePosted Oct 23, 2012, 12:17 PM
For Each c As Control In Me.Container.Controls ?
.
.
.
VulpesPosted Oct 23, 2012, 11:31 AM
The following assumes that all the textboxes have been placed directly on the form and not in some container such as a Panel or GroupBox: