-
December 18th, 2005, 09:24 AM
#1
NumericUpDown - Number + unit
I would like to use a NumericUpDown and add the unit (feet, ...) after the number.
This is made by extending the NumericUpDown class and overriding the UpdateEditText method like that:
protected override void UpdateEditText()
{
//Let the base component format the number according to the different properties
base.UpdateEditText();
//Add the unit
base.ChangingText = true;
base.Text = base.Text + " " + unit;
base.ChangingText = false;
}
But the problem is when a user change a part of the text in the textbox,
the ParseEditText method cannot parse a string like "2 feet",
and i cannot override this method like it is not virtual or abstract in the base class (Why did Microsoft do that?).
Please help me to find a solution.
Thanks in advance
-
December 18th, 2005, 09:52 AM
#2
Re: NumericUpDown - Number + unit
Hi yala,
may it help to implement "numericUpDown1_Validating". So you can check the value entered in the box and evaluate it for your needs.
Regards
Jost
-
December 18th, 2005, 01:21 PM
#3
Re: NumericUpDown - Number + unit
From my exprerience with the NumericUpDown control - I advice you to go to different directions.
For example: Create a UserControl, put a NumericUpDown, so the TextBox will not be visible (resize it) and only the UpDown arrows will be shown. Add a TextBox. So far, the control looks exactly like a NumericUpDown, except the arrows doesn't do anything. So catch both TextChanged of the TextBox and ValueChanged of the NumericUpDown in order to sync those two.
Add a Value property, and a ValueChanged event, and you have got your self a fine custom NumericUpDown.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|