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

Property renaming?

Is there any way of renaming the properties of standard controls.

I want to create a TextBox control inherited from a normal textbox control,
but I want to use the property for something else. Let's say the program
sets the Text property to "Mickey", then I want the TextBox to Show
"Donald"?

And if the user enters "Donald" into the textbox and I query the TextBox's
text property, I want to read "Mickey"

Is that possible?

As I see it, it would entail renaming the text property, because the new
Text property you create would somehow have to link to the "real" text
property?!?!?

TIA,
Johnny J.
Apr 16 '07 #1
2 3019
"Johnny Jörgensen" <jo**@altcom.sewrote in message
news:uq**************@TK2MSFTNGP06.phx.gbl...
Is there any way of renaming the properties of standard controls.

I want to create a TextBox control inherited from a normal textbox
control, but I want to use the property for something else. Let's say the
program sets the Text property to "Mickey", then I want the TextBox to
Show "Donald"?

And if the user enters "Donald" into the textbox and I query the TextBox's
text property, I want to read "Mickey"

Is that possible?

As I see it, it would entail renaming the text property, because the new
Text property you create would somehow have to link to the "real" text
property?!?!?
You don't have to rename the property, you just override it and do the
conversions inside it before calling the base property:

public overrides string Text
{
get
{
if (base.Text=="Donald") return "Mickey";
else return base.Text;
}
set
{
if (value=="Mickey") base.Text="Donald";
else base.Text = value;
}
}

Apr 16 '07 #2
Great - I've got that under control now - Thanks a lot...

Johnny J.

"Alberto Poblacion" <ea******************************@poblacion.orgwro te
in message news:%2****************@TK2MSFTNGP03.phx.gbl...
"Johnny Jörgensen" <jo**@altcom.sewrote in message
news:uq**************@TK2MSFTNGP06.phx.gbl...
>Is there any way of renaming the properties of standard controls.

I want to create a TextBox control inherited from a normal textbox
control, but I want to use the property for something else. Let's say the
program sets the Text property to "Mickey", then I want the TextBox to
Show "Donald"?

And if the user enters "Donald" into the textbox and I query the
TextBox's text property, I want to read "Mickey"

Is that possible?

As I see it, it would entail renaming the text property, because the new
Text property you create would somehow have to link to the "real" text
property?!?!?

You don't have to rename the property, you just override it and do the
conversions inside it before calling the base property:

public overrides string Text
{
get
{
if (base.Text=="Donald") return "Mickey";
else return base.Text;
}
set
{
if (value=="Mickey") base.Text="Donald";
else base.Text = value;
}
}

Apr 16 '07 #3

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

Similar topics

3
by: mathieu gagnon | last post by:
Hello, I'm new to this newsgroup and I have small question. With something like this : <form name="a"><input name="name"></form> Is it possible to get the name of the form (a) and access the...
43
by: Steven T. Hatton | last post by:
Now that I have a better grasp of the scope and capabilities of the C++ Standard Library, I understand that products such as Qt actually provide much of the same functionality through their own...
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...
2
by: Russell Mangel | last post by:
I am trying to create a property which returns an enum. The following class does not work, can someone fix it? I am using VS2003 C++ public __gc class Drive { public: Drive(){} __property...
10
by: Tony Abate | last post by:
I am working on an ASP.NET app that is going well except for one thing. I build my application and then move the .aspx file to a different directory. I can point the Codebehind property back to the...
5
by: Laurent | last post by:
Hi, I'm writing a Custom Control which have a public property named DataAdapter: <Category("Données")> _ Public Property DataAdapter() As SqlDataAdapter Get Return _dataAdapter End Get...
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??...
0
by: David W | last post by:
I have a very simple class that just stores a number of strings so I can use them in an ArrayList bound to a Repeater. There is no validation or calculations needed for the properties. Is there...
18
by: Academia | last post by:
I let the use modify the text of a combobox and then I replace the selected item with the new text (in Keyup event). But if he sets the Text property to an empty string ("") that sets the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
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...
0
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...

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.