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?
.NET ProgrammingVisual Basic.NET

Avatar of undefined
Last Comment
Nasir Razzaq

8/22/2022 - Mon
Nasir Razzaq

Try this

?CurrentCell.EditType Is TypeOf(DataGridViewTextBoxEditingControl)
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
Nasir Razzaq

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Your help has saved me hundreds of hours of internet surfing.
fblack61