I have a DataGridView where the cells in a column can have differnt cell types.
For example the cell in row 1 has the cell type DataGridViewTextBoxCell. And the cell in row 2 has the cell type DataGridViewImageCell.
I have created a method that does something if the mouse is over a cell of that column:
private void DataTableCellMouseEnter(object sender, DataGridViewCellEventArgs e)
{
if
(
e.RowIndex >= 0 // If the current row is not the header.
&& e.ColumnIndex == dataGridViewDMSSettings.Columns["Example"].Index // And if the current column is the example column.
)
{
// Something happing here.
}
}
Now I want to add a comparsion of the cell type to run the code only if the cell type is DataGridViewImageCell.
I have tried to add...
&& dataGridViewDMSSettings.Rows[e.RowIndex].Cells["Example"].GetType() == DataGridViewImageCell
... but I'm getting the IntelliSense massag DataGridViewImageCell is type and invalid in the current context.
Does someone have a solution for this?
Aucun commentaire:
Enregistrer un commentaire