Alarm Clock -- Time Picker - c#

I am trying to write a radio alarm clock as a bit of programming practice, I have successfully got a clock working in a line or two. When it comes however to having the use select an alarm time I don't know how to collect the information.
A date time picker can pass a date and time it would seem, but I can only figure out how to select the date which is the part I don't want.
Are there any other objects i can put on a form so a user can select a time to set the alarm?

If you like to manipulate only the Time with a DateTimePicker, the following code should work according to this MSDN article:
timePicker.Format = DateTimePickerFormat.Time;
timePicker.ShowUpDown = true;

Related

Scheduler Calendar datetime Picker time intervals

I need scheduler pop up datetime picker with one hour intervals. I tried this thing after changing outer Html of the popped input screen it will display data in correct way but their are issues in reading the selected data. It read wrong dates after i change the Popup. Please refer the attached images for more info. And want to define time range 8.00 am to 6.00 pmenter image description here
From the provided information it's not clear how exactly you are setting the corresponding option of the DateTimePicker, however the described scenario works as expected on my side - please check the example below:
http://dojo.telerik.com/inonu

How to add a custom display mode to calendar

Is there a way to add a new custom Display Mode to the WPF Calendar control nad how can it be done?
First, I want to describe my problem more in detail.
In my application I need a date (and time) picker in one control to select first a single date and then the time for this date.
The control (as it is) has three display modes which are Decade (showing 12 Years), Month (showing the 12 months of the selected year) and Days (showing the days of the selected month).
What I want to do is, adding another display mode "Hours" which then will show the 24 hours of the selected day.
So there are many problems.
How to add this view?
How to avoid closing the popup after selecting a date? -> it should switch to hours instead and close after selecting the hour
How to add the arrows in the last view to show 12 hours and the halfs on page one of the hours view
How to bind all this to the underlying datetime object which I am interested in at most because it contains what the user selected ;-)
Hope the problem is clear. If there is no direct way to add a view to existing Calendar control than any idea how to solve this would be appreciated.
You could try the Extended WPF toolkit, if you are looking for a out-of-the-box solution. It does not do exactly what you are describing, but it does allow you to select a time in addition to a date.
But if it's not enough, I am pretty sure you will have to make a completely new component. In most cases, a restyling of a component is sufficient to add new features, but in this case, you would most likely have to rewrite it from scratch.
As a workaround, we made a separate hour selection component, which were displayed on the side of the calendar. It's simpler than to rewrite the whole thing anew.

Pass DatePicker.Value of one form to another form?

i have a login form that accepts an admin and ordinary users.
when an admin logs-in, his form has two DateTimePickers.
the first DateTimePicker allows the admin to choose a date that will serve as a minimum date = MinDate.
the second DateTimePicker allows the admin to choose a date that will serve as a maximum date = MaxDate.
click ok and both MinDate and MaxDate should be saved even when the application exited.
now, if an ordinary user logs-in his form has one DateTimePicker which allows him to choose a date. however, that DateTimePicker has a limited range defined by the MinDate and MaxDate from the admin form.
i have seen tutorials do this but they only use text/strings which are easy to manipulate.
please help... sorry if there's no "try" code here, i just cant do it.
You should save the values the Admin provides in a database.
When the non-admin user visits the form, you will use the values in the database to set the minimum and maximum dates.
Then when the OK or Save button is pressed you validate the values against the values stored in the database.

DateTime Picker In WinForm How To Pick Time? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
DateTimePicker: pick both date and time
I'm using a WinForm DateTime picker and it does a fantastic job of choosing dates, but I don't know how to do times. It looks like a time is associated with the value, so maybe there's a way to use this to pick a time?
If there is no built in way to do this, I'll just create another box for the time and modify the DateTime value from the DateTime picker.
Thanks!
You can use the built in DateTime picker by adding a custom format string as follows:
DateTimePicker.ShowUpDown = true;
DateTimePicker.CustomFormat = "hh:mm";
DateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
Enjoy!
You can either choose the datepicker to have a "long" date, even only "time" or you can create your custom date.
I always use this format, as it's the most easy one to understand for users (IMHO): yyyy.MM.dd HH:mm
This can be done in the designer the fastest, just change the property.
Or, change it in the program with
YourDatePicker.Format = DateTimePickerFormat.Custom;
YourDatePicker.CustomFormat = "yyyy.MM.dd HH:mm";
The DateTimePicker works pretty much like how setting the Windows clock works. If you set the ShowUpDown property to true, it displays a spin control to the right of the DateTimePicker. If you then click on a section of the control, such as the time in hours, and then hit the up or down arrow of the spin control, it will change the time in hours.
Also, if you want to use a custom DateTime format, change the Format property to Custom and set the flags you'd like. For example, MM dddd yyyy HH:mm:ss. For an explanation of all the custom format specifiers, here's the full list of them from MSDN.
Hope that helps.

C# and Month Calendar, selecting multiple dates

I am making a program that will help people "book" orders for a department in C#. They need to be able to choose multiple dates in different months.
I would prefer to have it so they can click a date, and then shift click another one to select all dates between those two, and control clicking as well, to do single selection/deselection. They have to be able to move between months while still retaining all the dates they clicked for the previous month, this way they can overview the dates they've selected to make it easier.
What is the best way to do this? Should I use Visual Studio's default month calendar or is there a more flexible one that exists?
You can make it work by detecting clicks on dates and then add or remove the clicked date from the bolded dates. Implement the MonthCalendar's MouseDown event:
private void monthCalendar1_MouseDown(object sender, MouseEventArgs e) {
MonthCalendar.HitTestInfo info = monthCalendar1.HitTest(e.Location);
if (info.HitArea == MonthCalendar.HitArea.Date) {
if (monthCalendar1.BoldedDates.Contains(info.Time))
monthCalendar1.RemoveBoldedDate(info.Time);
else
monthCalendar1.AddBoldedDate(info.Time);
monthCalendar1.UpdateBoldedDates();
}
}
Just one problem with this, it flickers like a cheap motel. No fix for that.
The WinForms MonthCalendar supports selection of a Range, from Start to End but not the (de)selection of individual dates with Ctrl. So it seems it does not meet your requirements.
Just a quick note: If you resize the MonthCalendar it will show more months. Together with nobugz' answer that might give you a working solution.
Assuming that you are using WPF...
I would recommend that you create a simple ListBox and bind the ItemsSource property to the Calendar's SelectedDates property. As the user selects and deselects days from the Calendar, they will be added to or removed from the list.
In addition, you could create a DateSpan class and a ValueConverter to group dates in a series into your DateSpan class. You could then apply the converter to the SelectedDates property so that when the user uses Shift-Select, they will see a date span rather than a bunch of dates (assuming that's a bad thing). The logic wouldn't be too complex.
There are plenty of third-party tools out there, but no matter which control you use the core problem will remain: you want the user to be aware of all selected items, but you don't want to show every single month that contains a selected day at the same time. The best answer I can think of would be a list.

Categories

Resources