473,799 Members | 3,310 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1968
"Peter Gast" <pe********@tis cali.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.GetPropert ies.

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.AppendPrope rty(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*******@free net.deschrieb im Newsbeitrag
news:O2******** ******@TK2MSFTN GP02.phx.gbl...
"Peter Gast" <pe********@tis cali.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.GetPropert ies.

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********@tis cali.deschrieb
Hi Armin,
I have a 3rd party control and the parameters has to be given like
this (for ex.)
prp = ctl.AppendPrope rty(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
2992
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 NameChange. during runtime it works fine. if the name of the control has changed the event is fireing. (for example: designtime name of the button is btnOk, on a second button
7
3020
by: Shimon Sim | last post by:
I have a custom composite control I have following property
2
1380
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 Me.Controls.Add(Me.MyLabel) MyLabel.Text = "This is a label created during runtime."
8
10481
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
1752
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 runtime. Any assistance would be greatly appreciated. The code is as follows: In the class I declared the private variable strDatabasePath public partial class UserControl1 : UserControl { //... other code private string strDatabasePath;
7
1646
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?? Example would be ......Code Dim ObjA As New ObjectA
14
5237
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
1512
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... fred will appear as the Name of Button1, however, the handler for Button1 works still works as well... Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
1
1356
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 ReadOnly Property MyVar As Double Get Return _MyVar End Get
0
9541
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,...
1
10231
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10027
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
9073
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
7565
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
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5463
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...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.