问题
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:
a) Is this even possible to do?
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)
Any help or knowledge is greatly appreciated!!!
回答1:
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 DateTimePicker
but 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".
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).
来源:https://stackoverflow.com/questions/17556698/is-it-possible-to-resize-a-datetimepicker-or-monthcalendar-control-in-vb-net