473,396 Members | 2,093 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,396 software developers and data experts.

Using reflection to set properties.

Hi,
How to set the TextBox text property using Reflection.
Or to that matter any property of a control.
Iam having trouble writing a function of the style

public static void SetPropertyValue(Object target, string
property_name(as the text or width), object propertyvalue)
{
target - get type;
type- property of given name;
use reflection to set the value;
}
Can also please suggest some good tutorials on reflection.

Thanks
Suresh
Nov 15 '05 #1
1 28382
Suresh <su**********@hotmail.com> wrote:
How to set the TextBox text property using Reflection.
Or to that matter any property of a control.
Iam having trouble writing a function of the style

public static void SetPropertyValue(Object target, string
property_name(as the text or width), object propertyvalue)
{
target - get type;
Type type = target.GetType();
type- property of given name;
PropertyInfo prop = type.GetProperty (name);
use reflection to set the value;
prop.SetValue (target, propertyValue, null);
} Can also please suggest some good tutorials on reflection.


I'm afraid I don't know of any specifically, but the MSDN class and
method descriptions are pretty good.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Nov 15 '05 #2

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

Similar topics

0
by: ParkerV | last post by:
I am building a generic data access component. The module pulls a list of all the OLE DB providers currently installed on the machine (using the registry) and allows the user to select a...
2
by: Dawid Mostert | last post by:
Hi, I'm trying to get a list of properties from a hierarchy of classes, using reflection. Using Type.GetProperties(), I get the list back in "reverse hierarchy order" (derived class...
4
by: Brian Brane | last post by:
I have properties that wrap DataRow columns as in: public int aNumber { get{ return m_DataRow; } set{ m_DataRow = value; } } If the column happens to contain DBNull, I get a cast exception...
0
by: John R. | last post by:
I have a class that I am serializing. I put on the properties I don't want to serialize. I want to deserialize it to itself like this: XmlSerializer deserializer = new...
2
by: Robert W. | last post by:
I'm trying to write a utility that will use Reflection to examine any data model I pass it and correctly map out this model into a tree structure. When I say "any" , in fact there will only be 3...
9
by: Mario Vázquez | last post by:
Hi, I have a component which exposes an extended property. I want to edit this property using a UITypeEditor. The problem is that when the designer raises my UITypeEditor sends a reference of...
1
by: Stu | last post by:
Hi, I am trying to write a detailed logging system for a site. The client basically wants us to save the values of the properties on the page every time someone presses a save button. I have...
3
by: Steve Amey | last post by:
Hi all I am using reflection to read the values of properties from a class. The class is returned from a Web Service so I have to access the class using FieldInfo (Using VS 2003 which converts...
2
by: diego | last post by:
hi everyone, i have a sub that opens a form given the form's name as string and opens it using System.Reflection. How can I set the form's properties at runtime. Here is my code. Public Sub...
2
by: Martin Eckart | last post by:
Hi guys, I have a class which contains ~ 200 properties. Out of those 200 properties I need to access 10 (which I know beforehand already) via reflection in another class. Currently I am doing...
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:
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.