471,350 Members | 1,803 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

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

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
Feb 12 '06 #1
2 3604
Nabeel Moeen wrote:
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
Feb 12 '06 #2
>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

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

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by AlexS | last post: by
3 posts views Thread by Mike in Paradise | last post: by
3 posts views Thread by the fuzz | last post: by
5 posts views Thread by J L | last post: by
9 posts views Thread by Gugale at Lincoln | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.