Reputation: 33
Here is my code. I was trying to test the SelectedDate for my program so the user can click on the date and it'll make it into a string. However, when the SelectedDate tag has a red line under it that is indicating that:
'monthCalendar1' does not contain a definition for 'SelectedDate' and no accessible extension method 'SeclectedDate' accepted a first argument of type 'monthCalendar' could be found (are you missing a using directive or an assembly reference?).
private void monthCalendar1_SelectedDate(object sender, DateRangeEventArgs e)
{
txtDay.Text = monthCalendar1.SelectedDate.ToString("dd");
}
[]
Upvotes: 1
Views: 62
Reputation: 4191
you can use it like this:
var selectedDate = (DateTime.Parse(e.Start.ToShortDateString())).Day;
or
txtDay.Text = (DateTime.Parse(e.Start.ToShortDateString())).Day.ToString();
Upvotes: 1