protected void Calendar1_DayRender(object sender, DayRenderEventArgs e) { if (e.Day.IsWeekend) { //IsSelectable布尔属性控制日期是否可被选择 e.Day.IsSelectable = false; } if (e.Day.IsOtherMonth) { //e.Cell属性代表一个日期框 e.Cell.Text = "-"; } //检查日期是否为3月5号。 if (e.Day.Date.Day == 5 && e.Day.Date.Month == 3) { e.Cell.BackColor = System.Drawing.Color.Yellow; //向该列添加静态文本 Label lbl = new Label(); lbl.Text = "<br />学习雷锋好榜样!"; e.Cell.Controls.Add(lbl); } Calendar1.SelectedDate = DateTime.Now.AddDays(2).Date; //下面的代码将使用SelectedDates选中2008年3月的每个星期天 SelectedDatesCollection theDates = Calendar1.SelectedDates; theDates.Clear(); theDates.Add(new DateTime(2008, 3, 2)); theDates.Add(new DateTime(2008, 3, 9)); theDates.Add(new DateTime(2008, 3, 16)); theDates.Add(new DateTime(2008, 3, 23)); }
public void AddTask(DateTime dt) { List <ListOfTasks> ls = new List <ListOfTasks>(); SelectedDatesCollection theDates = calander1.SelectedDates; theDates.Clear(); theDates.Add(dt); ViewModel vm = new ViewModel(popAlert); vm.getAll(ls); foreach (Task t in ls[0].Tasks.ToList()) { DateTime d = t.DateTask; theDates.Add(d); } foreach (Task t in ls[1].Tasks.ToList()) { theDates.Add(t.DateTask); } foreach (Task t in ls[2].Tasks.ToList()) { theDates.Add(t.DateTask); } //theDates.Add(new DateTime(2000, 2, 9)); //theDates.Add(new DateTime(2000, 2, 16)); //theDates.Add(new DateTime(2000, 2, 23)); }
public void ClearMethod() { ArrayList list = new ArrayList(); SelectedDatesCollection s = new SelectedDatesCollection(list); s.Add(DateTime.Today); s.Clear(); Assert.AreEqual(0, s.Count, "A1"); }
//Highlight dates on calendar private void HighliteDatesOnCalendar() { try { SelectedDatesCollection dates = ClndOfStuff.SelectedDates; dates.Clear(); DateTime today = DateTime.Today; dates.Add(today); foreach (ToDoRecord date in thingsToDos) { dates.Add(Convert.ToDateTime(date.Date)); } } catch { } }