Datetimepicker禁用VB.NET [英] Datetimepicker disable VB.NET

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

问题描述

大家好!

我只是对每个人有一个简单的问题.是否可以在DateTimePicker中禁用某些月份?我正在做一个接受日期范围的程序.但是,最大范围是6个月.例如,如果我在DateTimePicker1中选择July,则DateTimePicker2中的值应仅为8月,9月,10月,11月,12月.我如何禁用1月,2月,3月,4月,5月和6月?谢谢!

x
Janna

Hi everyone!

I just have a quick question for everyone. Is it possible to disable some of the months in a DateTimePicker? I''m doing this program that accepts a date range. However it''s maximum range is 6 months. For example, if i choose July in DateTimePicker1, the values in DateTimePicker2 should only be August, September, October, November, December. How will i disable the months January, February, March, April, May and June? Thanks!

x
Janna

推荐答案

类似的内容将为您提供帮助:

Something like this would help you:

DateTimePicker1.MinDate = New DateTime(DateTime.Now.Year, DateTime.Now.Month, 1)
DateTimePicker1.MaxDate = DateTimePicker1.MinDate.AddMonths(6)



此代码会将控件限制为仅显示当前月份和接下来的6个月.您可以在 MinDate 中传递第一个DateTimePicker的月份.



This code will restrict the control to show only the current month and the upcoming 6 months. You can pass first DateTimePicker''s month in MinDate .


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

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