Natavia Finnie
asked on
vb.net How save and Load all textbox data on form to to a file
I am trying to save the values from textboxes and other controls recursively when my form has:
(1) tabcontrols with multiple tabPages
(2) on each tabPage are:
(a) several groupboxes, within a GroupBox
(b) panels, textboxes, and combboxes on the several groupboxes
I would like to use a similar method below but I don't get all the textboxes
For Each controlType As Control In Me.Controls
If TypeOf controlType Is TabControl Then
For Each tabpage As Control In controlType.Controls
If TypeOf controlType Is GroupBox Then
For Each txtBox As Control In controlType.Controls
If TypeOf txtBox Is TextBox Then
outputFile.wplWriteLine(tx tBox.Name, Trim(txtBox.Text))
End If
Next
End If
Next
End If
Next
(1) tabcontrols with multiple tabPages
(2) on each tabPage are:
(a) several groupboxes, within a GroupBox
(b) panels, textboxes, and combboxes on the several groupboxes
I would like to use a similar method below but I don't get all the textboxes
For Each controlType As Control In Me.Controls
If TypeOf controlType Is TabControl Then
For Each tabpage As Control In controlType.Controls
If TypeOf controlType Is GroupBox Then
For Each txtBox As Control In controlType.Controls
If TypeOf txtBox Is TextBox Then
outputFile.wplWriteLine(tx
End If
Next
End If
Next
End If
Next
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Be aware that GetNextControl() only returns controls that have TabStop set to True (which it normally is for TextBoxes, though it could be turned off for whatever reason).
ASKER
@Mike Tomlinson,
The GetNextControl() works great at this point. But you say if TabStop was set to false that the function would not work? I assume the function you have include does work if TabStop is, some how, set to false?!?!
The GetNextControl() works great at this point. But you say if TabStop was set to false that the function would not work? I assume the function you have include does work if TabStop is, some how, set to false?!?!
Correct, his implementation does not look at the TabStop to determine if the control is returned (although it could).
-saige-
-saige-
You'd only change TabStop to False if you don't want that Control to be visited when the user hits the Tab key. That's not normally the case for a TextBox, but it is possible. Just wanted to make you aware of that caveat.
@Eric - I was not aware of that method. ;)
-saige-