364,033 Members | 4774 Browsing Online
Community for Developers & IT Professionals
Bytes IT Community

Property List

Jim Heavey
P: n/a
Jim Heavey
I want to write a routine which will list all of the propetries and all
property names for a particular object, say a DataColumn. I there a way
for me to do this without manually looking up each property name and the
property value?


Thanks in advance for your assistance!!!!!!!!!!!
Nov 15 '05 #1
Share this Question
Share on Google+
2 Replies


Miha Markic
P: n/a
Miha Markic
Hi Jim,

You might take a look at reflection.
Type.GetProperties method is what you need.

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
www.rhand.com

"Jim Heavey" <JimHeavey@nospam.com> wrote in message
news:Xns945CD9E514AB4JimHeaveyhotmailcom@207.46.24 8.16...[color=blue]
> I want to write a routine which will list all of the propetries and all
> property names for a particular object, say a DataColumn. I there a way
> for me to do this without manually looking up each property name and the
> property value?
>
>
> Thanks in advance for your assistance!!!!!!!!!!![/color]


Nov 15 '05 #2

Jan Tielens
P: n/a
Jan Tielens
I suggest you take a look at the PropertyGrid control:
http://msdn.microsoft.com/library/de...ngpropgrid.asp
If you have used Microsoft® Visual Basic® or Microsoft Visual Studio .NET
then you have used a property browser to browse, view, and edit the
properties of one or more objects. The .NET Framework PropertyGrid control
is core to the property browser that is in Visual Studio .NET. The
PropertyGrid control displays properties for any object or type, and it
retrieves the item's properties, primarily using reflection. (Reflection is
a technology that provides type information at run time.)

Otherwise, if you want to do it all manually, you can use refelection:
object o;

foreach(System.Reflection.PropertyInfo pi in o.GetType().GetProperties())
{
MessageBox.Show(pi.Name);
}
object o;

foreach(System.Reflection.PropertyInfo pi in o.GetType().GetProperties())
{
MessageBox.Show(pi.Name);
}


--
Greetz,
Jan
__________________________________
Read my weblog: http://weblogs.asp.net/jan
"Jim Heavey" <JimHeavey@nospam.com> schreef in bericht
news:Xns945CD9E514AB4JimHeaveyhotmailcom@207.46.24 8.16...[color=blue]
> I want to write a routine which will list all of the propetries and all
> property names for a particular object, say a DataColumn. I there a way
> for me to do this without manually looking up each property name and the
> property value?
>
>
> Thanks in advance for your assistance!!!!!!!!!!![/color]


Nov 15 '05 #3

Post your reply

Help answer this question



Didn't find the answer to your C# / C Sharp question?

You can also browse similar questions: C# / C Sharp