Shadow Fiend Shadow Fiend - 1 month ago 16
Vb.net Question

One row selector in all Datagridview

Based on what you see below is the sample of a datagridview that an item has been selected.

enter image description here

Here is my question what if I have a more than 1 Datagridview? I mean 5 Datagridview like this.

enter image description here

All of them contains 1 column only. Based on the 1st image, the row selector or the blue one select an item.

My question is how can I make all of the datagridview only have one row selector?

What happens is when i selected each of them all of it has a row selected 5 selections.

How can I make 1 row selector for all of them.

Thinking of changing the Selection Color but I think that's not applicable.

TYSM for future help.

Muj Muj
Answer

Try this maybe it is more easy to edit if you add more grid

Private Sub ClearSelectedCells(ByVal Identifier As Integer)
    If Identifier = 1 Then 'for datagrid 1
        dg2.ClearSelection()
        dg3.ClearSelection()
    ElseIf Identifier = 2 Then 'for datagrid 2
        dg1.ClearSelection()
        dg3.ClearSelection()
    'and so on
    .
    .
    End If
End Sub


Private Sub dg1_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles dg1.CellClick
    ClearSelectedCells(1)
End Sub

'and other gridcellclick
.
.
Comments