When I display my Calendar, I select a certain date by default:
myCalendar.SelectedDate = myDateTime;
The problem is that the month that is displayed doesn't change. It stays at the current month. I searched high and low for a way to display a certain month.
How can I force the Calendar to display the month that contains the selected date?
Have you tried using the DisplayDate property? More here.
Related
I have a datetime picker in windows form. When i am selecting a date it shows the last selected date and current date. But i want to shows only current date always. It should not show last selected date and current date(both) on the selection dropdown.
public FieldControl()
{
InitializeComponent();
dtpDate.Value = DateTime.Now;
}
Hello Kumar is right,
but what is sense of selectable date and time component where is only one option to select?
Isn't better to make datetimepicker disabled? At least it's less confusing for user and by default actual date is selected when datetimepicker is dispayed.
Jaroslav
Try this :
you can get just today's date as a DateTime using the Today property:
dtpDate.Value = DateTime.Today;
if you want to show only current date in your datepicker then use this code:
dtpDate.MinDate = dtpDate.MaxDate = DateTime.Now;
For more information
Refer this link
You can't do it on the picker. But you can fake it. Resize the dateTimePicker so it only shows the pick button. Then place it next to a textbox. In the onClose event you write the selected value to the textbox, and set the value of the dateTimePicker back to Today.
On my form I have a clear button that is supposed to reset the form back to it's original settings, and as such, I need to de-select any dates a user has selected on my month calendar, but cannot figure out how to do this.
So, is there a way to remove all dates selected by the user on a month calendar?
You can set the Selection start and end to a specific date.
var today = DateTime.Today;
monthCalendar1.SelectionStart = today;
monthCalendar1.SelectionEnd = today;
do you mean something like this: http://msdn.microsoft.com/en-us/library/system.windows.forms.monthcalendar.removeallboldeddates.aspx
Or something like this:
calendar.SetDate(DateTime.Now)
I am trying to set the date to "todays " date in the rad date picker but all it does is it selects it in the calendar but the box where the date is displayed is empty (i.e 12/2/2012) is not showing... Here is my line of code, (i have seen some examples in google but they are all javascript, i need to do it on the back end C#).
rdpShipDate.Calendar.SelectedDate = DateTime.Today;
That line above just selecs the date in the calendar but the box is still empty.
Any help would be much appreciated.
Thanks
Have you tried:
rdpShipDate.SelectedDate = DateTime.Today;
friends,
i am using asp.net calendar control on page.
dynamically i am assigning it previous month date value.
it selects that date which is fine but not month
so the calendar shows current month when i use previous button then that date is selected.
any one guide me what is the solution?
my code
calstarting.SelectedDate = item.StartDate; // previous month date
calending.SelectedDate = item.EndDate; // previous month date
any help would be appreciated.
You should use
Calendar1.TodaysDate= item.StartDate;
Calendar1.SelectedDate = item.StartDate;
Instead of SelectedDate use TodaysDate and then use SelectedDate to show that date selected.
i found the solution.
in order to show previous date with that month and date selected on the screen there are two ways...
both working for me.
calControl1.SelectedDate = item.StartDate;
calControl1.TodaysDate = item.StartDate;
OR
calControl2.SelectedDate = item.EndDate; // to select that date
calControl2.VisibleDate = item.EndDate; // to select that perticular month on calender quite hidden attribute
I use Telerik RadCalendar ASP.NET control. How I can in code reset selected date? (Set no selected Date)
From their site:
http://demos.telerik.com/aspnet-ajax/calendar/examples/programming/clientsideapi/defaultcs.aspx
unselectDate(date); //Takes a triplet representation of a date and if valid deselects it in the calendar.
unselectDates(dates); //Takes an array of triplets representing dates and if valid deselects them in the calendar.
First you can find what dates are selected with get_selectedDates()
Then put them in the unselect method.
var selectedDates = get_selectedDates();
unselectDates(selectedDates);
If you dont know what dates are selected maybe you can reload the calendar.
If you want to clear the selection server-side then this should work:
RadCalendarObject.SelectedDates.Clear();