Hi
I do not understand your question, but you mention multiple DataGridViews (hopefully you have datasources as datatables?)
Anyway, here is a stand alone example that will allow differentiation between various DataGridViews, and based on user selection, displays a Label with identity info on User selection.
There may be a need (not shown here) to cycle through cells in a row, or columns in a DGV etc and that is quite simple. Combined with the code shown here, you could deal with any DGV in the same way (you are right in using column names rather than indexes - a necessity with multiple possible varieties being used)
' Form1 with
' DGV1, DGV2, DGV3 And DGV4 (all blank)
' and a Label1
Public Class Form1
Dim dt1, dt2, dt3, dt4 As New DataTable
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
With dt1
.Columns.Add("Col1-1", GetType(String))
.Columns.Add("Col2-1", GetType(String))
.Columns.Add("Col3-1", GetType(String))
End With
dt2 = dt1.Clone
dt3 = dt1.Clone
dt4 = dt1.Clone
dt1.Rows.Add("1-111", "1-222", "1 - 333")
dt2.Rows.Add("2-111", "2-222", "2 - 333")
dt3.Rows.Add("3-111", "3-222", "3 - 333")
dt4.Rows.Add("4-111", "4-222", "4 - 333")
DGV1.DataSource = dt1
DGV2.DataSource = dt2
DGV3.DataSource = dt3
DGV4.DataSource = dt4
End Sub
Private Sub DGV1_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles DGV1.CellClick, DGV2.CellClick, DGV3.CellClick, DGV4.CellClick
Dim DGV As DataGridView = DirectCast(sender, DataGridView)
Label1.Text = DGV.Name & " Column " & e.ColumnIndex.ToString & " Row " & e.RowIndex.ToString & " value = " & DGV(e.ColumnIndex, e.RowIndex).Value.ToString
End Sub
End Class
Hi
When you opt for granular validation, in most case, you are down to the individual item 9such as you have), and simplifying is very limited (as you have found). I can't see much more to offer.
One thing. Is each DataGridView datasource a Datatable? DataTables do offer other opportunities where the datatype can be used for validation which means any validation is not dependant on column names/indexes, and to a certain extent, can reduce the code size.