【问题标题】:Highlight selected date in VB.NET MonthCalendar在 VB.NET MonthCalendar 中突出显示选定的日期
【发布时间】:2010-04-19 21:11:15
【问题描述】:

我在 vb.net 中使用 MonthCalender 控件来选择日期。我能够将选定的日期保存到数据库,还可以检索并加粗先前选定的日期。但是即使日期是粗体的,它也不会在表单加载时显示。它仍然突出了今天的日期。我该怎么做才能突出显示以前选择的日期。我也想禁用选择日期范围。

我的代码如下。

'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

【问题讨论】:

    标签: vb.net


    【解决方案1】:

    您还需要调用SetDate方法或设置SelectionStart/SelectionEnd属性来设置当前选择的日期:

    '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
    

    如果您只处理一个日期,DateTimePicker 可能会起作用;忽略时间部分。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-03-28
      • 1970-01-01
      • 2021-07-29
      • 2014-12-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多