views:

323

answers:

2

Hello, I'm not very experienced with .NET development, so forgive me if I've missed something obvious.

My scenario is quite simple: my program is going to deal with both the Imperial and Metric systems of measurement. I need an input control that will be able to elegantly house {feet, inches} and {meters, centimeters} (only one set at a time).

From what I've seen in VC#'s Control Toolbox (Winforms .NETF 3.5), I'm looking for a mix of MaskedTextBox, NumericUpDown, and DateTimePicker.

Namely:

  • MaskedTextBox's ability of filtering user input
  • NumericUpDown's ability of [in/de]crementing the user-selected [sub-]unit of measurement
  • DateTimePicker's ability of "breaking apart" information in a single control. I'm specifically interested in breaking apart say feet and inches while still displaying them on the same control

I should also point out that I'm most interested in replicating DateTimePicker's ability to keep separate pieces of input in a single control.

I would greatly appreciate your thoughts as to what base control I should sub-class in order to achieve this functionality.

Cheers!

+1  A: 

Have you looked at this code project article which might be a starting point.

Mitch Wheat
Thanks, but the link's pointing to the wrong URI. I'll gladly read the article when it's fixed. =)
Apologies! Fixing now...
Mitch Wheat
Thanks Mitch, checking it out...
A: 

I think DateTimePicker isnt enough flexible to make that.

You should create a composite user control. The main control should contain:

  • Three NumericUpDown control (year, month, day)
  • Delegate events to every Validate event (instead of masked textbox)
  • Show a Calendar control when ie. user click into the NumbericUpDown control (or you can dedicate an '...' labelled button on the right)

Or yoou can search on CodeProject or Codeplex for opensource, and Telerik and DevX for shareware components.

boj