Solved

Extending NumericUpDown

Posted on 2004-08-19
9
351 Views
Last Modified: 2008-02-01
Hi everyone ..
again .. I come up with a somehow difficult question

Everything I need is the NumericUpDown Control .. But there has to be a change ...

I want that control to display a unit behind the value ..

Example:
I want a control which can output ("100 V"). When I press the Up-Button it should switch to "101 V".

Does anyone know how to do this ?

The reason:
I have one base form, from which another form is derived. Only the base class should contain code, not the derived one. So If a user wants to develop a form based upon my base class, the feature that the numericupdown can display a unit should already be available.
(I don't want a custom control - the user should be able to drag/drop the NumericUpDown control from the toolsbox in visualstudio onto the form)

Another possible solution would be:
* If the user chooses the NumericUpDown control, it should be automatically replaced by a user control (designed by me)


I give out 500 points .. since I have no idea how to do that :)
0
Comment
Question by:somnatic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
9 Comments
 
LVL 4

Author Comment

by:somnatic
ID: 11841433
3rd possible solution:

A simple textBox is used to display text and hold a number at the same time (number 13 -> text 13V).

BUT: The developer only must dragdrop a normal TextBox from the Toolbox to the Form ..
0
 
LVL 10

Assisted Solution

by:eternal_21
eternal_21 earned 50 total points
ID: 11842331
Why not use a DomainUpDown control and you can populate it with the values ("0 V", "1 V", "2 V", ...)?
0
 
LVL 4

Author Comment

by:somnatic
ID: 11844535
because it might contain values like 0.1 V or 0.001 A as well .. but 2000V may be possible as well ..

0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 96

Expert Comment

by:Bob Learned
ID: 11852382
One suggestion that I would have would be to add code in the base class that scans for NumericUpDown controls, and add label controls that would be positioned next to each of the controls, and accept whatever unit that user wishes.

Bob
0
 
LVL 4

Author Comment

by:somnatic
ID: 11853902
hmm  .quite problematic since it's likely that there are multiple numericupdown controls (close) next to each other ...

and I can't tell a developer who uses my "template" to "leave some space between numericUpDowns" ..

if you know what I mean ..
I could resize them .. but problematic as well ..
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11853990
Well, if you don't want a custom control, then you have a very narrow opportunity for success, and it would require some very complex magic to accomplish, which is beyond my capabilities.

You would need to be able to detect a NumericUpDown control being dropped onto a form in design time, and I wouldn't know how to accomplish that.  I would be very interested if someone did, though:)

Bob
0
 
LVL 4

Author Comment

by:somnatic
ID: 11854381
I feared it would be that hard ..

What about:
I create a inherited, say .. TextBox with some functions which suit my needs well ..

I call it NumericTextBox and derive it from TextBox
I'd do all of this in my base form ..

When another developer now creates a form which is inherited from mine.

He adds, say . .2 textboxes to it

Could I make my NumericControl replace his textboxes or would he have to change all occurences of Control.TextBox to NumerictextBox

??
Any idea about that ?
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 450 total points
ID: 11854525
I think that process is called transmogrification, and I am not sure how that would work, and even if it would be possible.  Are you thinking that you would add the up/down functionality to the TextBox control.  

The main problem that I can see right off the bat, is where would this NumericTextBox come from.  It would have to be in a DLL, and if it were possible you would have to do some serious bending over backwards to get the reference into the users project without them having to do anything.  

IMHO I think that you should seriously consider creating a custom control that combines a configurable label with an NumericUpDown control.  It would be the solution with the least amount of complexity.

Bob
0
 
LVL 4

Author Comment

by:somnatic
ID: 11911607
ok ..
since no perfect idea came up I do now use a custom control ..
well . .actually it's an inherited control (I used TextBox to inherit from, since I want to display some text as well)  ... but it's inside a DLL .. so ...

bah .. never mind .. thanks for helping ..
:)
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
create dataset from text files to go on winforms gridview 3 36
Nested forach loop to linq 3 42
Fastest way to get file count in MS Server 2012 3 35
async questions 5 48
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question