How to read data back to the controls of the interface for DGV and checkedListBox in

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

' this is part of the saveIt function
Dim cntrl As Control = Me
      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)
                                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)
                                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
                            '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 ****

                    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)
                            End With
                    End Select
                End If

Open in new window

Natavia FinnieSenior Analyst Technical Focus ApplicationsAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ess KayEntrapenuerCommented:
This just requies a simple thing.  

add a new variable to act as the middleman

Dim Temptext as String

Next,  every outputFile.wplWriteLine(
you would want to replace to look like this :
Temptext ="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"

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.