DateTimePicker-like Input Control - c#

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!

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

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.

Related

C# User Control (with sequences). Navigate within WinForms

I'm looking for the best, most effecient way of implimenting user controls navigation based on events, below is the intended use.
I also don't know what is best, to have the next back button on the control or form.
Lastly, the next button may sometimes change and initially be validate on some controls and then if validated change to next if the validate is ok.
Ok the concept:
I have 1 primary user control with 3 checkboxes, behind each checkbox is a sequence of more user forms therefore, if all three are selected it should then load all three sequences one after another.
Regardless of how many are selected, all sequences end with the same final user control.
Basically I need to understand the best and most practicle way approach this (examples welcome).
There are lots of topics that cover winforms / user control navigation but I cannot seem to see a solution which pops out to me and fits my needs.
For compatibility with some systems, I have decided to use .net 3.5; should this make a difference in suggestions.
Feedback, links, code etc all welcome :)
I ran into a similar scenario some years ago. If memory serves, I approached it as follows:
Separate the navigation buttons into their own control that groups
the buttons together. Design this control to support docking.
In this control, provide distinct buttons for Back, Next, Finish and
Cancel. Provide separate properties on the control that determine
what the user can do: CanMoveBack, CanMoveForward, CanFinish, and
CanCancel. The container should be able to set these.
In the setter for the navigation properties, you want to be able to
adjust the visibility/disabled status of each of the navigation
buttons. Don't hot-swap text. That way, each button does one thing,
and only one thing. This keeps their event handlers nice and clean.
The user control itself should raise events: OnBackClicked,
OnNextClicked, OnFinishClicked, and OnCancelClicked. Your button
event handlers should raise these. The container should decide what
to do when they are clicked.

How to skip redundant line in DateTimePicker?

I'm using .NET's DateTimePicker in a dropdown UITypeEditor to show in a property grid. The DateTimePicker shows a redundant line that means you have to click twice to show the useful calendar bit. How can I hide it so it skips straight to the calendar?
Backstory: Previously used used MonthCalendar, which doesn't have the redundant line. However, MonthCalendar crops itself sporadically (when edit one date in the grid, then another), which looks bad.
I don't think that there is any (easy) way to remove this part because is what defines the DateTimePicker as opposed to MonthCalendar.
What you call "useful calendar bit" is actually a MonthCalendar, why don't you rely on this control instead?
Or if you don't want to rely on MonthCalendar, perhaps you should consider a custom DateTimePicker: lots of codes in internet (sample1, sample2); even creating one by your own (after getting some inspiration from the available ones). Anything before considering the option of modifying a so important part of the control.

custom control for large calendar

I'm starting from square one in trying to create a large calendar control. Most likely to take up the whole screen or something. It doesn't need to complex, just navigate to dates and display a line of text on specific days.
From researching this, sounds like I need to create my own custom control, which I have no idea how to do, moreover, how to achieve my objective.
Any insight?
Just finished a similar project here, you'll want to use DataGridView as your control first of all.
Then create functions to control the population of data based on what month/year it is, including extraneous variables like leap year, etc.
So for a start, functions like:
UpdateDaysInMonth(): Determine how many days for Jan,Feb,Mar, etc
UpdateMonth(): Did the user click next month or previous month?
UpdateColumns():
This will be based on your preference, my calendar had days 1-31 all the way across,
but if you're looking for a more traditional looking calendar it would be setup differently. For the days Sun-Sat, use the HeaderText for columns.
Once you have all the base data for what timeframe you're viewing, you can draw out the DataGridView.
Hope this helps, let me know if you have any more questions, and good luck!

Creating a breadcrumb control using FlowLayoutPanel in C#

I was thinking about ways to exploit the flow layout panel control, and I thought about the idea of using this control as a base for a breadcrumb control.
The standard I'm aiming for being the Windows 7 Explorer addressbar/breadcrumb-like.
The benefits is that you can put any control inside it, like drop-down, button - whatever ultimately inherits from the Control class.
I thought of using a stack to keep track of the order and synchronizing the Controls property.
Anyone have some ideas for this project? Is it viable? Anyone have experiences with FlowLayoutPanel, good or bad?
What do you expect from the answer?
You can use the FlowLayoutPanel to implement breadcrumbs (I once did one that used labels for the 'crumbs', separated by arrows (like the Win 7 control) )
It's easy enough to implement Push() and Pop() methods (Push should add the arrow and then the control you want to add) and the Pop() should remove the last control and the arrow before that)
The main consideration is what you do when the contents don't fit. My control didn't handle that (it didn't have to) but the Win 7 control cleverly hides the first part of the trail, replacing it with a << chevron. The FLowLayoutPanel doesn't do that for you.
Hope this helped you out?

Data templates in WinForms

I'm trying to have a grid that has items that have a custom layout/feel. If you have a look at the following http://mdavey.files.wordpress.com/2007/05/ldmain.jpg this is kinda what I am trying to do (see the aqua/red pods on the left and the graphs on the bottom right).
Under WPF/ASP.Net I would know how to do this but in WinForms I have no idea (I have never had to work on a WinForms app before). Like in WPF I would use Data Templates.
Hence I was wondering anyone knows of any good resources that goes through this or if anyone knows if its just as easy as creating a custom control, they having a grid that has one column and setting the type of that column to the custom control and then binding the data source to the grid???
Cheers Anthony
You may check Essential Grid - it seems to me it supports features you need.
There is an example for progress bar cell which you could use for the graphs on the right side:
http://www.syncfusion.com/products/user-interface-edition/windows-forms/grid/progressbar-cell
And they have Push Button cell type which you could use for your pods on the left side:
http://www.syncfusion.com/products/user-interface-edition/windows-forms/grid/push-button
You might also check DevExpress XtrGrid:
http://www.devexpress.com/products/net/controls/winforms/grid/dataediting.xml
http://www.devexpress.com/products/net/controls/winforms/grid/appearance.xml
In any case, I would search for a component - it takes quite a lot of time to do such things from the scratch.

Categories

Resources