2014-01-08 38 views
0

我试图通过使用以下代码来检查一个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是一种类型的,不能用作表达式。

+2

http://stackoverflow.com/questions/3167479/what-is-the-vb-net-equivalent-of-the-c -sharp-is-keyword – sdf

+0

它的工作..谢谢。但正如你所看到的,我可能从来没有发现过这个问题,因为它的标题非常不同。发布此链接作为答案,以便我可以标记它。 – Arbaaz

回答

0

我在小区click事件尝试这样完美的作品:

Type str = dgv.Columns[dgv.SelectedCells[0].ColumnIndex].CellType; 
相关问题