且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在VB.net中的DataGridView中启用行

更新时间:2022-03-11 07:09:54

在datagridview中启用行的四个条件
1.基础数据源支持编辑.
2.启用了DataGridView控件.
3. EditMode属性值不是EditProgrammatically.
4.单元格,行,列和控件的ReadOnly属性都设置为false.

Four conditions to enable row in datagridview
1. The underlying data source supports editing.
2. The DataGridView control is enabled.
3. The EditMode property value is not EditProgrammatically.
4. The ReadOnly properties of the cell, row, column, and control are all set to false.

' Make the the entire DataGridView read only.
Private Sub Button8_Click(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles Button8.Click

    For Each band As DataGridViewBand In dataGridView.Columns
        band.ReadOnly = True
    Next
End Sub