Type.GetType returns null for Systems.Windows.Forms.TextBox

G

Guest

Hi,

the foillowing line returns a null value
Type.GetType("System.Windows.Forms.TextBox")

why is that so ... and what should i do if i need to compare if the control
is a textbox or not?

Regards,
Nabeel
 
M

Markus Stoeger

Nabeel said:
Hi,

the foillowing line returns a null value
Type.GetType("System.Windows.Forms.TextBox")

why is that so ... and what should i do if i need to compare if the control
is a textbox or not?

Control someControl = ...;

if (someControl is Textbox) {
// it is!
}

hth,
Max
 
M

Mattias Sjögren

the foillowing line returns a null value
Type.GetType("System.Windows.Forms.TextBox")

why is that so ...

Because you didn't specify which assembly it should look in. You have
to include the full assembly qualified name.

and what should i do if i need to compare if the control
is a textbox or not?

The easiest way would be to reference System.Windows.forms.dll and
write

if (yourControl is TextBox) ...


Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top