473,394 Members | 1,709 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,394 software developers and data experts.

creating a form that will display all the properties of an object

Hello.

I have a project that consists of nine different objects, each serving
their own purpose. In the past I have just created a form for each
one, and then whenever you call, say, object.Display(), it would call
up the form associated with that object. This form only displays
information, it doesn't allow the user to edit any information. Is it
possible to find the properties of a certain object, and then loop
through creating labels and such for every property? I believe I've
heard the Reflection class mentioned somewhere, but from what I see in
the MSDN library, it may not be exactly what I'm looking for. I also
only want to display the properties I defined.

Thank you,
JJ L.
Nov 16 '05 #1
2 1517
JJ,

In order to do this, you would have to use reflection. You would use
reflection to get the property names, and then create UI elements that are
linked to those properties on the instance of the object you have.

An easier alternative would be to use the PropertyGrid class, which does
all of this for you.

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

"JJ L." <po******@gmail.com> wrote in message
news:69**************************@posting.google.c om...
Hello.

I have a project that consists of nine different objects, each serving
their own purpose. In the past I have just created a form for each
one, and then whenever you call, say, object.Display(), it would call
up the form associated with that object. This form only displays
information, it doesn't allow the user to edit any information. Is it
possible to find the properties of a certain object, and then loop
through creating labels and such for every property? I believe I've
heard the Reflection class mentioned somewhere, but from what I see in
the MSDN library, it may not be exactly what I'm looking for. I also
only want to display the properties I defined.

Thank you,
JJ L.

Nov 16 '05 #2
JJ L,

Reflection is exactly what you are after. Reflection is not a class it is
method for discovering inforamtion of objects and classes at run time as
well as dynamically creating objects and executing methods. If you want to
discover all the proerties and get their values of objects you know nothing
about Reflection is exactly what you need.

Look at
Object.GetType method and/or C# typeof operator
Type class
Type.GetProperties method
PropertyInfo class

If you need something like VS property browser, you have it out of the box.
Look at PropertyGrid component.

--
HTH
Stoitcho Goutsev (100) [C# MVP]
"JJ L." <po******@gmail.com> wrote in message
news:69**************************@posting.google.c om...
Hello.

I have a project that consists of nine different objects, each serving
their own purpose. In the past I have just created a form for each
one, and then whenever you call, say, object.Display(), it would call
up the form associated with that object. This form only displays
information, it doesn't allow the user to edit any information. Is it
possible to find the properties of a certain object, and then loop
through creating labels and such for every property? I believe I've
heard the Reflection class mentioned somewhere, but from what I see in
the MSDN library, it may not be exactly what I'm looking for. I also
only want to display the properties I defined.

Thank you,
JJ L.

Nov 16 '05 #3

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

Similar topics

4
by: Altramagnus | last post by:
I have 30 - 40 type of different window. For each type I need about 20 instances of the window. When I try to create them, I get "Error creating window handle" My guess is there is a maximum...
4
by: Kevin Myers | last post by:
Hello, Please forgive my reposting of this note with hopefully a more relevant subject line. On an Access 2000 form under Windows 2000 I would like to use a Kodak Image Edit Control to...
1
by: Dixie | last post by:
I wish to add some fields to an existing table in code. I am using the following code from rkc. CurrentDb.Execute ("ALTER TABLE MyTable ADD MyNewField Text 25") This works , but I need to also set...
8
by: Oenone | last post by:
Is it possible to create an object which can have methods and properties, but which can also be treated as a string? I'm trying to create a wrapper around the IIS Request.Form object which...
6
by: dbuchanan | last post by:
VS2005 I've been reading all the help I can on the topic (MSDN, other) but I can't make sense of this. Desired behavior; The user is to choose from the displayed list of the databound combobox...
4
by: tshad | last post by:
I am trying to set up an Image authorization where you type in the value that is in a picture to log on to our site. I found a program that is supposed to do it, but it doesn't seem to work. ...
10
by: Jake Forson | last post by:
Hi there, I'd like to re-create a form given only its resource file. I was going to simply read the resource file and re-create the "Form" object and all its controls as found in this file...
26
by: nyathancha | last post by:
Hi, How Do I create an instance of a derived class from an instance of a base class, essentially wrapping up an existing base class with some additional functionality. The reason I need this is...
9
by: Tarscher | last post by:
hi all, I have this seemingly simple problem. I have lost a lot of time on it though. When a user selects a value from a dropdownlist (static control) a dynamic control is generated. I have...
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:
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
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.