Connecting Tech Pros Worldwide Forums | Help | Site Map

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

Nabeel Moeen
Guest
 
Posts: n/a
#1: Feb 12 '06
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

Markus Stoeger
Guest
 
Posts: n/a
#2: Feb 12 '06

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


Nabeel Moeen wrote:[color=blue]
> 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?[/color]

Control someControl = ...;

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

hth,
Max
Mattias Sjögren
Guest
 
Posts: n/a
#3: Feb 12 '06

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


>the foillowing line returns a null value[color=blue]
>Type.GetType("System.Windows.Forms.TextBox")
>
>why is that so ...[/color]

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

[color=blue]
>and what should i do if i need to compare if the control
>is a textbox or not?[/color]

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

if (yourControl is TextBox) ...


Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Closed Thread