开发者

Highlight selected date in VB.NET MonthCalendar

I am using MonthCalender control in vb.net to select a date. I am able to save the selected date to DB and also retrieve and bold the previous selected date. But even though date is bolded it is not displayed when the form loads. It still highlights today's date. What Do i do to highlight the previous chosen dates. Also i want to disable choosing date range.

I ha开发者_开发技巧ve my code below.

'StartDate is a datetime object

  'check if there is any date chosen
  If Not IsNothing(StartDate) Then
    Me.mcSelectedDate.AddAnnuallyBoldedDate(StartDate)
    Me.mcSelectedDate.UpdateBoldedDates()
  End If


You also need to call the SetDate method or set the SelectionStart/SelectionEnd properties to set the currently selected date:

'StartDate is a datetime object

  'check if there is any date chosen
  If Not IsNothing(StartDate) Then
    Me.mcSelectedDate.SetDate(StartDate)
    Me.mcSelectedDate.AddAnnuallyBoldedDate(StartDate)
    Me.mcSelectedDate.UpdateBoldedDates()
  End If

If you're only dealing with a single date, a DateTimePicker might work instead; just ignore the time part.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜