Natavia Finnie
asked on
How to read data back to the controls of the interface for DGV and checkedListBox in vb.net
I have included snippets of my saveIt and my readIt functions for help.
I am able to save all the data in the controls to my .txt file. The read of the comboBox and textBox work great.
I would like to know, with you my current code, is there a way to automatically read the data when it is being saved as the code is saving it. At the time I am using a 'Select Case' statement if it is not a control name or cntrl.length > 0
I am able to save all the data in the controls to my .txt file. The read of the comboBox and textBox work great.
I would like to know, with you my current code, is there a way to automatically read the data when it is being saved as the code is saving it. At the time I am using a 'Select Case' statement if it is not a control name or cntrl.length > 0
' this is part of the saveIt function
Dim cntrl As Control = Me
Do
cntrl = Me.GetNextControl(cntrl, True)
Dim ctlChecklist As CheckedListBox
If TypeOf cntrl Is CheckedListBox Then
ctlChecklist = cntrl
If ctlChecklist.Name = "MethodsListBox" Then
If ctlChecklist.CheckedIndice<wbr ></wbr>s.Count > 0 Then
For thisIndex As Integer = 0 To ctlChecklist.CheckedIndice<wbr ></wbr>s.Count - 1
outputFile.wplWriteLine("A<wbr ></wbr>nalysis[" & thisIndex + 1 & "]name", ctlChecklist.Items(ctlChec<wbr ></wbr>klist.Chec<wbr ></wbr>kedIndices<wbr ></wbr>(thisIndex<wbr ></wbr>)).ToStrin<wbr ></wbr>g)
Next
End If
End If
End If
' Search for a DataGridView
Dim ctlDGV As DataGridView
If TypeOf cntrl Is DataGridView Then
ctlDGV = cntrl
If ctlDGV.Rows.Count > 0 Then
If ctlDGV.Name = "proteinDependentDGV" Then
'outputFile.wplWriteLine("<wbr ></wbr>DataGridVi<wbr ></wbr>ewName", ctlDGV.Name)
For thisRow As Integer = 0 To ctlDGV.Rows.Count - 1
outputFile.wplWriteLine("P<wbr ></wbr>rotein[" & thisRow + 1 & "]property", ctlDGV.Rows(thisRow).Cells<wbr ></wbr>("proteinP<wbr ></wbr>roperty").<wbr ></wbr>Value)
outputFile.wplWriteLine("P<wbr ></wbr>rotein[" & thisRow + 1 & "]value", ctlDGV.Rows(thisRow).Cells<wbr ></wbr>("proteinV<wbr ></wbr>alue").Val<wbr ></wbr>ue)
Next
End If
End If
End If
End Using
' this is part of the readIt function
Do While (Not fileReader.EndOfStream)
If Not fileReader.wplReadLine(varName, varValue) Then Continue Do
If varName = "" Then Exit Do
Dim parsedVarNameCI As New RegUtlLib.StringCI
RegUtlLib.WplUtl.WplParseTag(varName, parsedVarNameCI, arrayIndices)
Dim ctl As Control() = Me.Controls.Find(varName, True)
If ctl.Length > 0 Then
Dim ctlType As String = ctl(0).GetType().Name
If ctlType = "TextBox" OrElse ctlType = "ComboBox" Then
'Update the TextBox
If ctlType = "TextBox" Then
Dim tb As TextBox = ctl(0)
tb.Text = varValue
Else
'Update the ComboBox
Dim cb As ComboBox = ctl(0)
cb.Text = varValue
End If
End If
**** I want the code to read the DGV values and checkedListBox values here ****
Else
Select Case parsedVarNameCI
Case "ProteinEquivalenceVersion"
inputFileVersion = CDbl(varValue)
Case "changeHistory"
With histList
Dim newItem As New historyItem
Dim rowVals() As String = Split(varValue, "::")
newItem.historyDate = rowVals(0)
newItem.historyUser = rowVals(1)
histList.Add(newItem)
End With
End Select
End If
Loop
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.