It is possible to adjust the width of the DateTimePickerAdv when it is in standard format. The width of the DateTimePickerAdv is calculated by adding the following constraints:
C# //New font size is set here. this.dateTimePickerAdv1.Font = new Font("Tahoma", 13); this.dateTimePickerAdv1.ShowCheckBox = false; this.dateTimePickerAdv1.ShowUpDown = true; this.dateTimePickerAdv1.AutoSize = false; this.dateTimePickerAdv1.AutoSizeMode = AutoSizeMode.GrowOnly; this.dateTimePickerAdv1.Format = DateTimePickerFormat.Long; int updownWidth = 0, dropWidth = 0; //Calculating the UpDown and DropDown button width foreach (Control ctrl in this.dateTimePickerAdv1.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.dateTimePickerAdv1.Font.Size * this.dateTimePickerAdv1.Value.ToLongDateString().Length); this.dateTimePickerAdv1.Width = nWidth; VB ''Font is set Me.DateTimePickerAdv2.Font = New Font("Tahoma", 13) Me.DateTimePickerAdv2.ShowCheckBox = False Me.DateTimePickerAdv2.ShowUpDown = True Me.DateTimePickerAdv2.AutoSize = False Me.DateTimePickerAdv2.AutoSizeMode = Windows.Forms.AutoSizeMode.GrowOnly Me.DateTimePickerAdv2.Format = DateTimePickerFormat.Long Dim updownWidth As Integer = 0, dropWidth As Integer = 0 ''Calculating the UpDown and DropDown button width For Each ctrl As Control In Me.DateTimePickerAdv2.Controls If ctrl.GetType().ToString() = "Syncfusion.Windows.Forms.Tools.DateTimePickerUpDownButton" Then updownWidth = ctrl.Size.Width ElseIf 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.DateTimePickerAdv2.Font.Size * Me.DateTimePickerAdv2.Value.ToLongDateString().Length) Me.DateTimePickerAdv2.Width = nWidth Sample: http://websamples.syncfusion.com/Samples/KB/Tools.Windows/KB_DateTimeStandard/main.htm |
Article ID: | Published Date: | Last Revised Date: | Platform: | Control: |
1771 | 04/30/2011 | 07/10/2014 | WinForms | DateTimePickerAdv |
Tags:
|
|
or the page will be automatically redirected to sign-in page in 10 seconds.