473,779 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to determine the control has the specific properties or events or not?

ABC
I want to check the form's controls have or not the specific properties or
events. How to determine or gather the properties list under the run-time
environment?
Jan 3 '06 #1
4 4505
ABC,

You want to use Reflection for this. First, get the type of the object
through a call to GetType. Once you do this, you will want to call
GetProperties or GetEvents to get the properties or events.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"ABC" <ab*@abc.com> wrote in message
news:%2******** *******@tk2msft ngp13.phx.gbl.. .
I want to check the form's controls have or not the specific properties or
events. How to determine or gather the properties list under the run-time
environment?

Jan 3 '06 #2
ABC
I am a newie about Reflection. I have not any ideas about Reflection
concept. May I have some tutorials or artists from internet? Any
recommandation?
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:eS******** ******@TK2MSFTN GP14.phx.gbl...
ABC,

You want to use Reflection for this. First, get the type of the object
through a call to GetType. Once you do this, you will want to call
GetProperties or GetEvents to get the properties or events.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"ABC" <ab*@abc.com> wrote in message
news:%2******** *******@tk2msft ngp13.phx.gbl.. .
I want to check the form's controls have or not the specific properties or
events. How to determine or gather the properties list under the run-time
environment ?


Jan 3 '06 #3
What exactly are you trying to do? Simply knowing if something has a
particular property does not help if you do not know the behavior, and
reflection will not identify the behavior. If you provide more information,
than a simpler solution might work.

"ABC" <ab*@abc.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
I am a newie about Reflection. I have not any ideas about Reflection
concept. May I have some tutorials or artists from internet? Any
recommandation ?
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote
in message news:eS******** ******@TK2MSFTN GP14.phx.gbl...
ABC,

You want to use Reflection for this. First, get the type of the
object through a call to GetType. Once you do this, you will want to
call GetProperties or GetEvents to get the properties or events.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"ABC" <ab*@abc.com> wrote in message
news:%2******** *******@tk2msft ngp13.phx.gbl.. .
I want to check the form's controls have or not the specific properties
or events. How to determine or gather the properties list under the
run-time environment?



Jan 3 '06 #4
ABC -

Reflection allows you to programatically examine and work with objects
at runtime. This is a very powerful feature of .NET which allows you
to interact with objects which you may not know how to work with at
design time. With reflection, you can obtain information about
methods, constructors, fields, events, anything that is contained
within an object. Also, the objects which you wish to explore and work
with don't necessarily need to be public, so you can, for example, set
the value of a private field of an object even if it's marked as
private!

For your specific question, the code is relatively simple. For
example:

public bool HasProperty(obj ect control, string propertyName)
{
return control.GetType ().GetProperty( propertyName) != null;
}

public bool HasEvent(object control, string eventName)
{
return control.GetType ().GetEvent(eve ntName) != null;
}

So, for example, if you want to know if a control, has a property named
"Text", you'd simply do:

bool hasText = HasProperty(myC ontrol, "Text");

If you want to know if it has an event called "Clicked":

bool hasClicked = HasProperty(myC ontrol, "Clicked");
Hope this helps!

Brant Estes
Senior Consultant
Magenic Technologies


ABC wrote:
I am a newie about Reflection. I have not any ideas about Reflection
concept. May I have some tutorials or artists from internet? Any
recommandation?
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:eS******** ******@TK2MSFTN GP14.phx.gbl...
ABC,

You want to use Reflection for this. First, get the type of the object
through a call to GetType. Once you do this, you will want to call
GetProperties or GetEvents to get the properties or events.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"ABC" <ab*@abc.com> wrote in message
news:%2******** *******@tk2msft ngp13.phx.gbl.. .
I want to check the form's controls have or not the specific properties or
events. How to determine or gather the properties list under the run-time
environment ?



Jan 10 '06 #5

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

Similar topics

18
2889
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code that applies to all these events, but I need to have specific code execute when the form closes. The properties for this method are sender (the originator) and e (event arguments). I know how to get typeof (sender) to determine what form or...
5
2822
by: Richard Brown | last post by:
Ok, I've been looking through the .NET SDK docs and stuff. I'm wondering if you can provide a control extender that does generic validation or functionality just by dropping it on the form. For instance, using the IExtenderProvider interface, you can specify properties, but there is nothing documented about linking into a control's events. For instance, in my application, there are specific formatting, functionality and validation for...
0
9636
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9930
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8961
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.