Private Sub fillTextBoxes() Dim columnX As DataGridViewColumn Dim rowX As DataGridViewRow For Each columnX In dgView.Columns rowX = dgView.CurrentRow Me.Controls.Item(columnX.Name).Text = rowX.Cells(columnX.Name).Value.ToString Next End Sub
What I am trying to do is change the value of textboxes that were created based on the fields in a database that also
supplies the datagridview. The column name and the names of the text boxes are the same. My text boxes are nested in a tab page, a split container and a group box (allows the user to move the controls around on the form via another class) the datagrid view is also nested in a tab, and a second panel. What I want to do is when the user selects on cell from one row the text boxes fill with the contents from that row. The datagridview itself will also be editable, but the text boxes are there so the user can more easily see which data they are dealing with. I have looked quite a bit for a solution to this, but with the code I have currently I get the following error:
Object reference not set to an instance of an object.
on line 9.
~Mr.Wobbles

New Topic/Question
This topic is locked




MultiQuote






|