DataGridView read only cells

前端 未结 9 483
余生分开走
余生分开走 2020-12-09 10:57

I have a binded DataGridView that contains a large amount of data. The problem is that some cells has to be ReadOnly and also when the user navigates with TAB or ENTER betwe

9条回答
  •  难免孤独
    2020-12-09 11:29

    You can use CellBeginEdit event and set e.Cancel = True when you need disable the cell.

    Private Sub DataGridView_CellBeginEdit(sender As System.Object, e As System.Windows.Forms.DataGridViewCellCancelEventArgs) Handles DataGridViewMsg.CellBeginEdit
        If DataGridViewMsg.Rows(e.RowIndex).Cells("disable").Value = "Y" Then
            e.Cancel = True
        End If
    End Sub
    

提交回复
热议问题