Hi all,

i am trying to convert a dataGridView cell to a control

i used the codes

Control dat = new Control();
dat = Convert.ChangeType(dataGridView1[colIndex,rowIndex], typeof(Control));

I am fetching the values of colIndex and rowIndes from a index code... the problem is even though i tried many codes to convert, it does not work

The expection i am gettting is
"Can not implicitly convert an object to a control. An explicit convertion exist(are u missing a cast?)"

Any help
thanks
vince

Recommended Answers

All 2 Replies

What are you going to do with it when you convert it?
Are you just trying to add it to a panel or something?

Explicit Casting:

try
{
    Control myControl = (Control)myObject;
}
catch 
{
//Object did not conform to Control class...Do something about it.
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.