.net - 如何检查 DataGridView 单元格的类型?

标签 .net vb.net datagridview

我尝试使用以下代码检查 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/

相关文章:

c# - 不使用 Visual Studio 运行 ASP/C#

c# - .net 值类排序与 IComparable

vb.net - 当两个方法同名但参数不同时如何在VB.Net中实现接口(interface)

vb.net - 如何检查表中是否有内容

c# - 如何创建 mysql 更新查询以在 c#.net windows 应用程序的一条语句中更新多行

c# - 如何更改datagridview中的行颜色

c# - Azure CDN 端点使用 https 提供 502 错误网关

c# - NEST:创建别名并设置过滤器

c# - 在加载所有项目并将其显示在ListView中后,将触发哪个事件?

html - Visual Basic 登录页面导致错误(错误 BC30506 Handles 子句需要 WithEvents...)