473,382 Members | 1,180 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.

read name of property during runtime

Hi,
I need as a parameter for a control the names of my properties as a string.
How can I get the name of the property as a string during runtime

Example:
Private _MyVar As Double
Public ReadOnly Property MyVar As Double
Get
Return _MyVar
End Get
End Property

.....
MsgBox ( ???? MyVar.GetType ?????)
.....
The result should be "MyVar", I've got a tip to us Type.GetField(...), but
this expressions doesn't work.
Thanks Peter

Jun 29 '07 #1
3 1945
"Peter Gast" <pe********@tiscali.deschrieb
Hi,
I need as a parameter for a control the names of my properties as a
string. How can I get the name of the property as a string during
runtime

Example:
Private _MyVar As Double
Public ReadOnly Property MyVar As Double
Get
Return _MyVar
End Get
End Property

....
MsgBox ( ???? MyVar.GetType ?????)
....
The result should be "MyVar", I've got a tip to us
Type.GetField(...), but this expressions doesn't work.

Why do you need the name of a property? This does not make sense at all: If
you need the name of a property, you must know the name of which property to
get the name. That's...

I you want to get the name of all properties of a class, use
Type.GetProperties.

Do you want to get the /type/ of the property?

Maybe you are looking for the /value/ of an object's property while late
binding the property's name? Then Type.GetField should work.
"/Advanced/ Development Technologies":
http://msdn2.microsoft.com/en-us/library/cxz4wk15.aspx

Armin

Jun 29 '07 #2
Hi Armin,
I have a 3rd party control and the parameters has to be given like this (for
ex.)
prp = ctl.AppendProperty(Parent, id , "The value is", Me, "MyVar", "Here is
the comment to MyVar")
"The value is": This is displayed in the left column of a grid
Me: The class where the Property is a memher of
"MyVar": The property MyVar (Has to be written as a string, that
prevents unfortunately this parameter that it can be renamed automaticly by
IDE)

The value of the property is shown in the right col of the grid. I'm
wondering why a parameter is given such a way, but it is and I should have a
solution which "extract" the NAME of the variable to a string. I hope I've
explained it clear enough. Beside I'm not looking for the value of the
property.

I have still problems to use the suggested Type.GetField(..), Where I have
to write MyVar in this method? Can you give me the whole syntax, ideal with
the example MyVar? When I rename MyVar in the IDE the rename should be
appear in this expressions too.

Thanks Peter
"Armin Zingler" <az*******@freenet.deschrieb im Newsbeitrag
news:O2**************@TK2MSFTNGP02.phx.gbl...
"Peter Gast" <pe********@tiscali.deschrieb
>Hi,
I need as a parameter for a control the names of my properties as a
string. How can I get the name of the property as a string during
runtime

Example:
Private _MyVar As Double
Public ReadOnly Property MyVar As Double
Get
Return _MyVar
End Get
End Property

....
MsgBox ( ???? MyVar.GetType ?????)
....
The result should be "MyVar", I've got a tip to us
Type.GetField(...), but this expressions doesn't work.


Why do you need the name of a property? This does not make sense at all:
If
you need the name of a property, you must know the name of which property
to
get the name. That's...

I you want to get the name of all properties of a class, use
Type.GetProperties.

Do you want to get the /type/ of the property?

Maybe you are looking for the /value/ of an object's property while late
binding the property's name? Then Type.GetField should work.
"/Advanced/ Development Technologies":
http://msdn2.microsoft.com/en-us/library/cxz4wk15.aspx

Armin
Jun 29 '07 #3
"Peter Gast" <pe********@tiscali.deschrieb
Hi Armin,
I have a 3rd party control and the parameters has to be given like
this (for ex.)
prp = ctl.AppendProperty(Parent, id , "The value is", Me, "MyVar",
"Here is the comment to MyVar")
"The value is": This is displayed in the left column of a grid
Me: The class where the Property is a memher of
"MyVar": The property MyVar (Has to be written as a string, that
prevents unfortunately this parameter that it can be renamed
automaticly by IDE)

The value of the property is shown in the right col of the grid. I'm
wondering why a parameter is given such a way, but it is and I
should have a solution which "extract" the NAME of the variable to a
string. I hope I've explained it clear enough. Beside I'm not
looking for the value of the property.

I have still problems to use the suggested Type.GetField(..), Where
I have to write MyVar in this method? Can you give me the whole
syntax, ideal with the example MyVar? When I rename MyVar in the IDE
the rename should be appear in this expressions too.

Thanks Peter

I see now what you're trying, but I think it is not possible. If you rename
MyVar, you manually have to change the string "MyVar", too. The IDE has no
relation between the two. I don't see a way to do it because the 3rd party
control seems to always need a string, and as long as you need a string you
will always have to change the string manually.

In other words, there is no compiler support like "GetName(MyVar)".
Armin

Jun 29 '07 #4

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

Similar topics

4
by: Weinand Daniel | last post by:
i'd like to monitor changes of the "Control.Name" porperty during designtime. if the user changes the name in designer my event musst fire. i have created a own button control. with an event...
7
by: Shimon Sim | last post by:
I have a custom composite control I have following property
2
by: -BA- | last post by:
Hi! I wonder if it is possible to dynamically name a object (e.g. checkbox, combox etc.) during runtime. I know I can create a object during runtime like this: Me.MyLabel = New Label...
8
by: Jan Kucera | last post by:
Hi, I have structure like this: namespace Namespace { public class User { public Subnamespace.Settings Settings = new Subnamespace.Settings(); } namespace Subnamespace {
3
by: dave | last post by:
I am having trouble accessing a property set during run-time in a user control that I have built. The control is supposed to connect to a database using the path supplied by the developer at...
7
by: Nemisis | last post by:
Hi everyone, Can anyone tell me if it is possible to pass in a property of an object into a sub, and within that sub, find out the name of the item that was passed along with the property name??...
14
by: Frank | last post by:
I see that ImageFormat includes exif. But I can't find out if I've System.Drawing.Image.FromStream or something like it can read and/or write that format.
10
by: Rob | last post by:
I am reading a book that says that the "name" property can be altered only at design time and cannot be modified at runtime. Please explain this given the code below... If you click Button3......
1
by: Peter Gast | last post by:
Hi, I need as parameter for a control the names of my properties as a string. How can I get the name of the property as a string during runtime Example: Private _MyVar As Double Public...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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: 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...

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.