Reputation: 5549
I am trying to check the cell type of a DataGridView Cell by using following code:
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
I am getting DataGridViewCheckBoxCell
is a type and can not be used as an expression.
Upvotes: 2
Views: 7441
Reputation: 5068
Another method if you know the row and column indexes: dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].GetType().Name
Upvotes: 1
Reputation: 5301
i tried this in cell click event and works perfectly :
Type str = dgv.Columns[dgv.SelectedCells[0].ColumnIndex].CellType;
Upvotes: 2