2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
Date time formatIt 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 constraints.
C# 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.Value.ToString(this.dateTimePickerAdv3.CustomFormat).Length); this.dateTimePickerAdv3.Width = nWidth;
VB 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.
This page will automatically be redirected to the sign-in page in 10 seconds.