I have a program with 2 forms and both forms have their own grid. Grid1 is on form1, Grid2 is on form2. I want Grid2 to serve as a pop up window which is used for editing. When a user doubleclicks a row on Grid1, it should do a requery on just that row and display that single row on Grid2. I can’t figure out how to get the column names of the selectedrow then do a query on it’s unique identifers. What I have so far:
(This is on form1 by the way)
Public Sub dgvForm1_CellDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvForm1.CellDoubleClick
Dim i As Integer = 0
Dim rowIndex As Integer
Dim cellName as string
While dgvForm1.SelectedRows.Item(0).Cells(i).ColumnIndex < dgvForm1.ColumnCount
rowIndex = dgvForm1.SelectedRows.Item(0).HeaderCell.RowIndex
cellName = dgvForm1.SelectedRows.Item(0).HeaderCell.toString
Select Case cellName
Case "control_no"
Dim sControlNum = cellName.ToString
Case "store_id"
Dim sStoreNum = cellName.ToString
End Select
i = i + 1
End While
end sub
I simply just want the user to doubleclick a row that is displayed on a datagridview with many other records, and that triggers a doubleclick event. This would then loop through the selectedrow’s column names until it finds both control_id and store_id and gets their values. P.s. I tried google for a good hour or so but I had a hard time getting any techniques to work.
UPDATE:
I should probably add, this is a bound datagrid that uses sqlClient and its dataadapter/dataset method.
myTable.Columns.ColumnName.
Read more at http://msdn.microsoft.com/en-us/library/system.data.datacolumn.columnname.aspx