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

Casting inherited types

Jax
I have made a class called MoneyBox, this inherits from
textbox and does little more except put and keep a "£" at
the front of it.
But on one of my forms I have a textbox that is sometimes
used for currency input but sometimes it isn't.

What i'd like to know is if it is possible to change the
type of this box at run time from events that are fired on
earlier parts on the form.
At present i'm just sticking with the textbox and adding
a "£" label infront of it when it should be a moneyBox,
which is a little cack.
It has to be able to switch to moneyBox to TextBox and
back, is this reasonable or not possible?

Many thanks for those that the time out to answer me.
jax
Nov 15 '05 #1
2 1139
Hi Jax,

You could consider introducing a boolean property such as "MoneyModeEnabled"
which would turn your text box customizations on or off. An even better
solution would probably be to make this property of an enumerable type, say,
TextBoxStyle. This enumerable type would currently have two options -
Regular and Money, but could be extended to support more styles later.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Jax" <an*******@discussions.microsoft.com> wrote in message
news:08****************************@phx.gbl...
I have made a class called MoneyBox, this inherits from
textbox and does little more except put and keep a "£" at
the front of it.
But on one of my forms I have a textbox that is sometimes
used for currency input but sometimes it isn't.

What i'd like to know is if it is possible to change the
type of this box at run time from events that are fired on
earlier parts on the form.
At present i'm just sticking with the textbox and adding
a "£" label infront of it when it should be a moneyBox,
which is a little cack.
It has to be able to switch to moneyBox to TextBox and
back, is this reasonable or not possible?

Many thanks for those that the time out to answer me.
jax

Nov 15 '05 #2
Jax
Now that is a fine idea, and the concept of adding further
versions.
An almighty textbox would rise with the ability to
completely change it's functionality on the toggle of a
single property. Man it's a whole new world out there.
That is such a good idea. Thankyou.

jax
-----Original Message-----
Hi Jax,

You could consider introducing a boolean property such as "MoneyModeEnabled"which would turn your text box customizations on or off. An even bettersolution would probably be to make this property of an enumerable type, say,TextBoxStyle. This enumerable type would currently have two options -Regular and Money, but could be extended to support more styles later.
--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Jax" <an*******@discussions.microsoft.com> wrote in messagenews:08****************************@phx.gbl...
I have made a class called MoneyBox, this inherits from
textbox and does little more except put and keep a "£" at
the front of it.
But on one of my forms I have a textbox that is sometimes
used for currency input but sometimes it isn't.

What i'd like to know is if it is possible to change the
type of this box at run time from events that are fired on
earlier parts on the form.
At present i'm just sticking with the textbox and adding
a "£" label infront of it when it should be a moneyBox,
which is a little cack.
It has to be able to switch to moneyBox to TextBox and
back, is this reasonable or not possible?

Many thanks for those that the time out to answer me.
jax

.

Nov 15 '05 #3

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

Similar topics

1
by: Remco | last post by:
Hi, Let me try to simply explain my questions. I've created a portal site with different types of users, e.g. Portal Administrators and Normal Users. One base class SessionUser (has a enum...
1
by: Remco | last post by:
Hi, Let me try to simply explain my questions. I've created a portal site with different types of users, e.g. Portal Administrators and Normal Users. One base class SessionUser (has a enum...
2
by: Remco | last post by:
Hi, Let me try to simply explain my questions. I've created a portal site with different types of users, e.g. Portal Administrators and Normal Users. One base class SessionUser (has a enum...
0
by: Remco | last post by:
Hi, Let me try to simply explain my questions. I've created a portal site with different types of users, e.g. Portal Administrators and Normal Users. One base class SessionUser (has a enum...
9
by: Jess | last post by:
Hello, It seems both static_cast and dynamic_cast can cast a base class pointer/reference to a derived class pointer/reference. If so, is there any difference between them? In addition, if I...
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: 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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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...

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.