We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How can I change the width of the DateTimePickerAdv when it is set to custom format?

Platform: WinForms |
Control: DateTimePickerAdv |
Published Date: April 30, 2011 |
Last Revised Date: July 10, 2014


It is possible to adjust the width of the DateTimePickerAdv according to the custom format given. The width of the DateTimePickerAdv is calculated by adding the following:

  • Width of the DateTimePickerUpDownButton
  • Width of the DateTimePickerDropButton
  • Font size of the DateTimePickerAdv
  • The length of the DataTimePickerAdv's Value in custom format


this.dateTimePickerAdv3.ShowCheckBox = false;

this.dateTimePickerAdv3.ShowUpDown = true;

this.dateTimePickerAdv3.AutoSize = false;

this.dateTimePickerAdv3.AutoSizeMode = AutoSizeMode.GrowOnly;

this.dateTimePickerAdv3.Format = DateTimePickerFormat.Custom;

this.dateTimePickerAdv3.CustomFormat = "dd/MMM";

int updownWidth = 0, dropWidth = 0;

foreach (Control ctrl in this.dateTimePickerAdv3.Controls)


if (ctrl.GetType().ToString() == "Syncfusion.Windows.Forms.Tools.DateTimePickerUpDownButton")

updownWidth = ctrl.Size.Width;

else if (ctrl.GetType().ToString() == "Syncfusion.Windows.Forms.Tools.DateTimePickerDropButton")

dropWidth = ctrl.Size.Width;


//Sum up the width of drop down button, updown button and font.

int nWidth = dropWidth + updownWidth + Convert.ToInt32(this.dateTimePickerAdv3.Font.Size *


this.dateTimePickerAdv3.Width = nWidth;


Me.dateTimePickerAdv3.ShowCheckBox = False

Me.dateTimePickerAdv3.ShowUpDown = True

Me.dateTimePickerAdv3.AutoSize = False

Me.dateTimePickerAdv3.AutoSizeMode = AutoSizeMode.GrowOnly

Me.dateTimePickerAdv3.Format = DateTimePickerFormat.Custom

Me.dateTimePickerAdv3.CustomFormat = "dd/MMM"

Dim updownWidth As Integer = 0, dropWidth As Integer = 0

For Each ctrl As Control In Me.dateTimePickerAdv3.Controls

If ctrl.GetType().ToString() = "Syncfusion.Windows.Forms.Tools.DateTimePickerUpDownButton" Then

updownWidth = ctrl.Size.Width

Else If ctrl.GetType().ToString() = "Syncfusion.Windows.Forms.Tools.DateTimePickerDropButton" Then

dropWidth = ctrl.Size.Width

End If

Next ctrl

''Sum up the width of drop down button, updown button and font.

Dim nWidth As Integer = dropWidth + updownWidth + Convert.ToInt32(Me.dateTimePickerAdv3.Font.Size * Me.dateTimePickerAdv3.Value.ToString(Me.dateTimePickerAdv3.CustomFormat).Length)

Me.dateTimePickerAdv3.Width = nWidth



2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon