473,382 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

How to get the type of a control

Hello,

I created 3 custom controls: A, B and C.
Given a control how can I get its type and check if it is of type A, B
or C?

Thanks,
Miguel

Oct 31 '07 #1
4 1552
..GetType()????

--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless Author Plug
OWC Black Book 2nd Edition
Exclusively on www.lulu.com/owc
$19.99
"shapper" <md*****@gmail.comwrote in message
news:11**********************@57g2000hsv.googlegro ups.com...
Hello,

I created 3 custom controls: A, B and C.
Given a control how can I get its type and check if it is of type A, B
or C?

Thanks,
Miguel

Oct 31 '07 #2
If A.GetType() = B.GetType() Then.....

....or...

If GetType(A) = GetType(B) Then....

....or....

Select Case A.GetType.Name
Case B.GetType.Name
' Do something

Case C.GetType.Name
' Do something

End Select

"shapper" <md*****@gmail.comwrote in message
news:11**********************@57g2000hsv.googlegro ups.com...
Hello,

I created 3 custom controls: A, B and C.
Given a control how can I get its type and check if it is of type A, B
or C?

Thanks,
Miguel

Nov 1 '07 #3
maybe you could use the "IS" keyword/operator?
On Wed, 31 Oct 2007 20:12:56 -0400, "Scott M." <s-***@nospam.nospam>
wrote:
>If A.GetType() = B.GetType() Then.....

...or...

If GetType(A) = GetType(B) Then....

...or....

Select Case A.GetType.Name
Case B.GetType.Name
' Do something

Case C.GetType.Name
' Do something

End Select

"shapper" <md*****@gmail.comwrote in message
news:11**********************@57g2000hsv.googlegr oups.com...
>Hello,

I created 3 custom controls: A, B and C.
Given a control how can I get its type and check if it is of type A, B
or C?

Thanks,
Miguel
Nov 1 '07 #4
Yep, I realized that just as I was looking at my post. Replace "=" with
"Is" when checking a type against another type.
"John MJ Gorter" <jo*********@gmail.comwrote in message
news:g2********************************@4ax.com...
maybe you could use the "IS" keyword/operator?
On Wed, 31 Oct 2007 20:12:56 -0400, "Scott M." <s-***@nospam.nospam>
wrote:
>>If A.GetType() = B.GetType() Then.....

...or...

If GetType(A) = GetType(B) Then....

...or....

Select Case A.GetType.Name
Case B.GetType.Name
' Do something

Case C.GetType.Name
' Do something

End Select

"shapper" <md*****@gmail.comwrote in message
news:11**********************@57g2000hsv.googleg roups.com...
>>Hello,

I created 3 custom controls: A, B and C.
Given a control how can I get its type and check if it is of type A, B
or C?

Thanks,
Miguel

Nov 1 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Batista, Facundo | last post by:
Here I send it. Suggestions and all kinds of recomendations are more than welcomed. If it all goes ok, it'll be a PEP when I finish writing/modifying the code. Thank you. .. Facundo
2
by: CJack | last post by:
hi, i have a window form with different controls. i want to loop through all the controls and write the types and lables of each control in a file. I dnt know how to determine the type of a control...
2
by: Dave Leach | last post by:
I am writing a Windows MDI application in C#. I would like to cast an object to a specific type. I know that the object is of a compatible type. The code below shows what I would like to do, but...
11
by: Wolfgang Kaml | last post by:
I am not sure if this is more of an expert question, but I am sure that they are out there. I'd like to setup a general application or bin directory on my Win2003.Net Server that will hold some...
8
by: Leszek Taratuta | last post by:
Hello, I have the following code: // Load the MenuBar.ascx user control. The control defines SavePropertyEvent event. UserControl ctrl =...
3
by: amitbadgi | last post by:
I am getting teh following error while converting an asp application to asp.net, Exception Details: System.Runtime.InteropServices.COMException: Type mismatch. Source Error: Line...
15
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
3
by: | last post by:
For a given web form, I want to know what the +simplest+ way to add an attribute to all of a particular control type on that page. For example, I might want to add an onClick attribute to all...
6
by: Deckarep | last post by:
I want to be able to pass in a function a string say: "TextBox" Then I need a way to convert that string representation into a Type object so i can search through some controls and check their...
1
by: Jordan S. | last post by:
Using .NET 3.5, I'm wondering how to get a control's specific type (e.g,. "Button" and not simply "Control") after the control is inserted into a control hierarchy - when ParseControl is used. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.