Link to home
Start Free TrialLog in
Avatar of dgb
dgb

asked on

DataGridView CurrentCell.EditType

I want to know if the inline editor of my cell in a DataGridView is of the type DataGridViewTextBoxEditingControl.
I would like to know why I can't use this:

?CurrentCell.EditType Is DataGridViewTextBoxEditingControl
'DataGridViewTextBoxEditingControl' is a type and cannot be used as an expression.

The error message seems strange to me, because in an other piece of code I use something like this:

?TypeOf CurrentCell Is DataGridViewCell
True

As an alternative I have:

?CurrentCell.EditType Is (New DataGridViewTextBoxEditingControl).GetType
True

This probably will give me a lot of garabage collection.

I also could use this:

?CurrentCell.EditType.Name = "DataGridViewTextBoxEditingControl"
True

But I try to avoid this practice for obvious reasons (casing can change).


Why can I not use:

?CurrentCell.EditType Is DataGridViewTextBoxEditingControl

It seems like a good idea.

What should I use instead as best practice?
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Try this

?CurrentCell.EditType Is TypeOf(DataGridViewTextBoxEditingControl)
Avatar of dgb
dgb

ASKER

CodeCruiser thank you for your response.

I tried it and I get an error message:

?CurrentCell.EditType Is TypeOf(DataGridViewTextBoxEditingControl)
'Is' expected.

ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial