我尝试使用以下代码检查 DataGridView 单元格的单元格类型:
Private Sub DataGridView1_CellValueChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellValueChanged
If DataGridView1.Columns(e.ColumnIndex).Name = "ColCheck" Then
Dim cell As DataGridViewCell = DataGridView1.Rows(e.RowIndex).Cells("ColCheck")
If cell Is DataGridViewCheckBoxCell Then
End If
我得到 DataGridViewCheckBoxCell
是一种类型,不能用作表达式。
最佳答案
我在单元格点击事件中尝试了这个并且工作完美:
Type str = dgv.Columns[dgv.SelectedCells[0].ColumnIndex].CellType;
关于.net - 如何检查 DataGridView 单元格的类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20989734/