[2005] Insert value from textbox into datagridview? Code included
I have a list box that is populated with data. When an item from the listbox is double clicked, the value is displayed in a textbox on the form. With the click of the "Change" button, I want to push that textbox value to index 4 in my DGV. Here is what I tried with no luck.
This all occurs on the click event of the Change Button
PHP Code:
For Each row As DataGridViewRow In Form1.GroupDataList.SelectedRows
row.Cells(5).Value = txtSearch.Text
Next
Any ideas why this wouldn't work?
I don't get any errors, but nothing happens either.
Re: [2005] Insert value from textbox into datagridview? Code included
Are there any rows selected in the grid? If you want the cell at index 4 set then why are you specifying index 5 for the column?
Re: [2005] Insert value from textbox into datagridview? Code included
Oops, that was a typo. THe first part was also supposed to be "5". Yes, in the DGV it is returning one record, and I select that row.
Re: [2005] Insert value from textbox into datagridview? Code included
My guess is that you're referring to the wrong Form1 instance in your For loop. You're referring to the default instance. If you haven't displayed the default instance then you won't see the change. If this code is in the form itself then you should use Me, not Form1.