在 vb.net 的 DateTimePicker 中选择多个日期?
无论如何,我可以在 Vb.net 的日期时间选择器中选择多个日期吗?
Is there anyway i can select multiple dates in a Date Time Picker in Vb.net?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在月历中使用 BoldedDates 属性来获取 DateTime 对象的数组。您可以使用它来获取您的收藏,并在存储后最后清除粗体日期,以便可以重复使用。
Use BoldedDates Property in your month calendar to get the array of DateTime objects. You can use this to get your collection and finally clear the bold dates after storing it, so that it can be reused.
如果您想使用 DateTimePicker 选择日期范围,那么最好的方法是两个
DateTimePicker
控制一个起始日期和一个截止日期。然后,您可以在选择第一个日期时更改相反控件的日期,以确保 FromDate 在 ToDate 之前,反之亦然
如果您想使用
MonthCalendar
控件,您可以指定MaximumSelectionCount
属性,然后用户可以通过单击一个日期并按住 Shift 键单击另一个日期来选择日期。您可以检索用户使用
SelectionRange
或SelectionStart
和SelectionEnd
属性选择的日期这更复杂。一个建议 - 您可以使用
MonthCalendar
的BoldedDates
数组,当用户单击某一天时,您将其加粗。他们完成选择后您可以读取数组吗?也许其他人对此有建议?If you want to select a range of dates using a DateTimePicker, then the best way if probably two
DateTimePicker
controls a from date and a to date.You can then change the date of the opposite control when the first date is picked to make sure the FromDate is before the ToDate and vice versa
If you want to use a
MonthCalendar
control you can specify aMaximumSelectionCount
property and then the user can select dates by clicking on one and shift-clicking on another dateYou can retrieve the dates the user selected by using the
SelectionRange
, orSelectionStart
andSelectionEnd
propertiesThis is more complex. A suggestion - you could use the
BoldedDates
array of theMonthCalendar
and when a user clicks on a day, you bold it. You can then read the array after they have finished their selection? Maybe someone else has a suggestion for this?我找到了,并尝试一下。它有效,
原始来源来自
i found it, and try. it work,
original source from here
在现有
DateTimePicker
控件内无法执行此操作。最佳替代解决方案将取决于您的具体情况。背景是什么?如果您希望用户选择接近的日期(并且范围不太大),一个相当简单的解决方案是使用另一个允许在列表上进行多重选择的控件。
例如
CheckedListBox
或DataGridView
。然后用日期列表填充它。实际上为用户提供了一个日期选择列表。
There is no way to do this inside the existing
DateTimePicker
control.The best alternative solution will depend on your specific situation. What's the context? If you're expecting the user to pick dates which are close together (and the range isn't too big) a reasonably simple solution is to use another control which will allow multiselect on a list.
For example a
CheckedListBox
orDataGridView
.Then populate it with a list of dates. In effect offering the user a picklist of dates.