Reputation: 151
I was wondering if there is a way to disable the abillity of the user to select cells of the first column (the one with an arrow), but i still need the user to be able to select all other cells,exept the ones on the first column.
Upvotes: 1
Views: 1307
Reputation: 32288
If the selection is moved to the target column, using the DataGridView1.SelectionChanged
event you can prevent the selection focus, setting the DataGridView1.CurrentCell
to next column cell in the same row.
This works for selection events generated by both Mouse clicks and cursor movement.
Private blockedColumn As Integer = 0
Private Sub DataGridView1_SelectionChanged(sender As Object, e As EventArgs) Handles DataGridView1.SelectionChanged
If DataGridView1.CurrentCell.ColumnIndex = blockedColumn Then
DataGridView1.CurrentCell =
DataGridView1(blockedColumn + 1, DataGridView1.CurrentCell.RowIndex)
End If
End Sub
You could set dataGridView1.Columns(0).Frozen = True
anyway, for other uses. But it's not necessary.
Upvotes: 3