I have a list of DataGridViews:
Dim grid As New System.Collections.Generic.List(Of DataGridView)
and I use a loop to add as many grids as I need:
for x = 0 to 5
AddHandler grid(x).CellClick, AddressOf gridCellClick
For the click event, I've found what appears to be the most cumbersome possible method to determine which grid the user clicked (x):
Private Sub gridCellClick(ByVal sender As Object, ByVal e As EventArgs)
For x = 0 To grid.Count - 1
If CType(sender, Control).Equals(grid(x)) Then Exit For
MsgBox("You Clicked Grid # " & x)
Anyone got anything bit more elegant ? Hoping a single line of code would do it.
Thanks a lot!