【发布时间】:2023-03-04 21:16:01
【问题描述】:
伙计们,我想将 datagridview 设置为只接受一行,但我很难做到这一点。 表示在第一行之后不允许用户添加新行。 所以 datagridview 总是只有一行。虽然在 Visual Basic 中 任何帮助将不胜感激。
【问题讨论】:
标签: visual-studio-2010 datagridview
伙计们,我想将 datagridview 设置为只接受一行,但我很难做到这一点。 表示在第一行之后不允许用户添加新行。 所以 datagridview 总是只有一行。虽然在 Visual Basic 中 任何帮助将不胜感激。
【问题讨论】:
标签: visual-studio-2010 datagridview
Private Sub Datagridview1_CellBeginEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DatagridviewCellCancelEventArgs) Handles DataGridView.CellBeginEdit
For Each r As DataGridViewRow in DataGridView1.Rows
If r.IsNewRow AndAlso DataGridView1.CurrentRow.Index = 0
e.Cancel = False
Else
e.Cancel = True
End If
Next
End Sub
【讨论】: