Windows日历VB SelectedDates [英] Windows Calendar VB SelectedDates

查看:80
本文介绍了Windows日历VB SelectedDates的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在VB中的Web应用程序中,我可以使用selectedDates获取所有选定的日期。 在VB中的Windows应用程序中,我找不到SelectedDates。 如何获取Windows VB日历中选择的所有日期的值?



Edcal

In a Web application in VB I can use selectedDates to get all the selected days.  In a Windows application in VB I do not find a SelectedDates.  How do I get the values of all the dates selected in a Windows VB Calendar?


Edcal

推荐答案

您将使用具有开始和结束的SelectionRange属性从这里获取日期的日期。

You would use SelectionRange property which has a start and end date where you can from this get dates between.

这是一个迭代器方法,可以做到这一点。

Here is a iterator method that will do this.

Public Iterator Function EachDay(ByVal pFrom As Date, ByVal pThru As Date) As IEnumerable(Of Date)
    Dim day = pFrom.Date

    Do While day.Date <= pThru.Date
        Yield day
        day = day.AddDays(1)
    Loop
End Function

也许在按钮点击事件

Dim selectedRange As SelectionRange = MonthCalendar1.SelectionRange
For Each day As DateTime In EachDay(selectedRange.Start, selectedRange.End)
    Console.WriteLine(day)
Next


这篇关于Windows日历VB SelectedDates的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆