How can I close and validate a calendar?
These are my two calendars that pop-up using a button
the calendar code
private void cdrCalendarStart_SelectionChanged(object sender, System.EventArgs e)
{
{
//displaying the selected date into a textbox
tbstartdate.Text = cdrCalendarStart.SelectedDate.ToShortDateString();
cdrCalendarStart.Visible= false; //hiding the calendar.
}
}
private void cdrCalendarFin_SelectionChanged(object sender, System.EventArgs e)
{
{
//displaying the selected date into textbox
tbfinishdate.Text = cdrCalendarFin.SelectedDate.ToShortDateString();
cdrCalendarFin.Visible= false; //hiding the calendar.
}
}
the buttons
private void btstartdate_Click(object sender, System.EventArgs e)
{
/*this sets the date format once date is selected to appear in the textbox */
try
{
if(tbstartdate.Text.Trim() != "")
cdrCalendarStart.SelectedDate = Convert.ToDateTime(tbstartdate.Text);
}
catch
{}
cdrCalendarStart.Visible= true; //showing the calendar.
}
private void btfindt_Click(object sender, System.EventArgs e)
{ /*This sets the date format once date is selected to appear in the textbox */
try
{
if(tbfinishdate.Text.Trim() != "")
cdrCalendarFin.SelectedDate = Convert.ToDateTime(tbfinishdate.Text);
}
catch
{}
cdrCalendarFin.Visible= true; //showing the calendar.
}
I want to be able to have a close option of the calendar and validate the dates, so when the user selects that date and then when it gets to selecting the finish date I need show that the user can only select the days after what was slected in the start date.
Can anyone help?
Loading
Amy TurnbullPosted Nov 1, 2007, 10:26 AM
Amy TurnbullPosted Oct 26, 2007, 4:37 AM
Amy TurnbullPosted Oct 25, 2007, 3:56 AM
Jan MontanoPosted Oct 24, 2007, 10:48 PM
// end date
private void dateTimePicker2_ValueChanged(object sender, EventArgs e)
{
if (dateTimePicker2.Value < dateTimePicker1.Value)
{
MessageBox.Show("End date can't be less than start date!");
}
}
//start date
private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
{
if (dateTimePicker1.Value > dateTimePicker2.Value)
{
MessageBox.Show("Start date can't be greater than end date!");
}
}