是否可以在 VB.net 中调整 DateTimePicker 或 MonthCalendar 控件的大小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17556698/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 14:12:40  来源:igfitidea点击:

Is it possible to resize a DateTimePicker or MonthCalendar Control in VB.net

vb.netcalendarresizedatetimepicker

提问by user2494918

Essentially I want to re-size my dateTimePicker control to fit its parent container. I have tried to do this both through the Control Editor and programmatically but I simply cannot get the drop down calendar to expand at all. So 2 part question:

本质上,我想重新调整 dateTimePicker 控件的大小以适合其父容器。我尝试通过控件编辑器和以编程方式执行此操作,但我根本无法展开下拉日历。所以2部分问题:

a) Is this even possible to do?

a) 这甚至可能做到吗?

b) Is there an easy-to-implement solution to having a good looking calendar that fits its parent field? (i.e. using a data grid or something similar)

b) 是否有一个易于实施的解决方案来拥有适合其父字段的漂亮日历?(即使用数据网格或类似的东西)

Any help or knowledge is greatly appreciated!!!

非常感谢任何帮助或知识!!!

回答by varocarbas

The size of both objects is fixed and defined by the size of its font. Thus you might change its size by affecting the font size. This works fine with DateTimePickerbut does not seem to work with MonthCalendar. After a quick research I have found a pretty curious recommendation on the MSDN forum: "you can consider third party MonthCalendar controls to meet your requirement temporarily".

两个对象的大小都是固定的,并由其字体大小定义。因此,您可以通过影响字体大小来更改其大小。这适用于,DateTimePicker但似乎不适用于MonthCalendar. 经过快速研究,我在MSDN 论坛上发现了一个非常奇怪的建议:“您可以考虑使用第三方 MonthCalendar 控件来暂时满足您的要求”。

There are quite a few third-party options (after a really quick search I found this) or you might even create one by your own. I personally haven't ever had any problem with the in-built controls but if the size is so important for you I guess that you would have to search/develop something by your own.

有很多第三方选项(经过快速搜索后我找到了这个),或者您甚至可以自己创建一个。我个人从未对内置控件有任何问题,但如果大小对您来说如此重要,我想您将不得不自己搜索/开发一些东西。

Further recommendation: rely on WPF which does contain a resizable control (DatePicker). I want to highlight here that I don't like WPF at all and that thus this recommendation is because I don't see any other option (inside .NET).

进一步建议:依赖 WPF,它确实包含一个可调整大小的控件 ( DatePicker)。我想在这里强调,我根本不喜欢 WPF,因此这个建议是因为我没有看到任何其他选项(在 .NET 中)。