2
2
layout : post
3
3
title : Customization of SfDateTimeEdit | Windows Forms | Syncfusion
4
4
description : Customize the visibility of UpDown Button, Key Navigation Support and DropDown Popup alignment support
5
- platform : WindowsForms
5
+ platform : windowsforms
6
6
control : SfDateTimeEdit
7
7
documentation : ug
8
8
---
@@ -30,13 +30,13 @@ The following code snippets illustrates the customization.
30
30
31
31
{% highlight C# %}
32
32
33
- sfDateTimeEdit1.Style.BorderColor = Color.Red;
33
+ sfDateTimeEdit1.Style.BorderColor = Color.Red;
34
34
35
35
{% endhighlight %}
36
36
37
37
{% highlight VB %}
38
38
39
- sfDateTimeEdit1.Style.BorderColor = Color.Red
39
+ sfDateTimeEdit1.Style.BorderColor = Color.Red
40
40
41
41
{% endhighlight %}
42
42
@@ -61,40 +61,32 @@ The following code snippets illustrates the same.
61
61
62
62
{% highlight C# %}
63
63
64
- //Setting the DropDown Fore color
64
+ //Setting the DropDown Fore color
65
65
66
- this.dateTimeEdit.Style.DropDown.ForeColor = Color.Purple;
66
+ this.dateTimeEdit.Style.DropDown.ForeColor = Color.Purple;
67
+ this.dateTimeEdit.Style.DropDown.HoverForeColor = Color.Yellow;
68
+ this.dateTimeEdit.Style.DropDown.PressedForeColor = Color.Green;
67
69
68
- this.dateTimeEdit.Style.DropDown.HoverForeColor = Color.Yellow;
69
-
70
- this.dateTimeEdit.Style.DropDown.PressedForeColor = Color.Green;
71
-
72
- //Setting the DropDown Back color
70
+ //Setting the DropDown Back color
73
71
74
72
this.sfDateTimeEdit1.Style.DropDown.BackColor = Color.Aqua;
75
-
76
73
this.sfDateTimeEdit1.Style.DropDown.HoverBackColor = Color.Gray;
77
-
78
74
this.sfDateTimeEdit1.Style.DropDown.PressedBackColor = Color.Orange;
79
75
80
76
{% endhighlight %}
81
77
82
78
{% highlight VB %}
83
79
84
- 'Setting the DropDown Fore color
85
-
86
- Me.dateTimeEdit.Style.DropDown.ForeColor = Color.Purple
80
+ 'Setting the DropDown Fore color
87
81
88
- Me.dateTimeEdit.Style.DropDown.HoverForeColor = Color.Yellow
82
+ Me.dateTimeEdit.Style.DropDown.ForeColor = Color.Purple
83
+ Me.dateTimeEdit.Style.DropDown.HoverForeColor = Color.Yellow
84
+ Me.dateTimeEdit.Style.DropDown.PressedForeColor = Color.Green
89
85
90
- Me.dateTimeEdit.Style.DropDown.PressedForeColor = Color.Green
91
-
92
- 'Setting the DropDown Back color
86
+ 'Setting the DropDown Back color
93
87
94
88
Me.sfDateTimeEdit1.Style.DropDown.BackColor = Color.Aqua
95
-
96
89
Me.sfDateTimeEdit1.Style.DropDown.HoverBackColor = Color.Gray
97
-
98
90
Me.sfDateTimeEdit1.Style.DropDown.PressedBackColor = Color.Orange
99
91
100
92
{% endhighlight %}
@@ -105,34 +97,57 @@ The following code snippets illustrates the same.
105
97
106
98
![ Customize the drop down] ( appearance-images/drodownbackcolor.png )
107
99
100
+ ## Customize default calendar Icon in drop-down button
101
+
102
+ The [ DateTimeIcon] ( https://help.syncfusion.com/cr/windowsforms/Syncfusion.WinForms.Input.SfDateTimeEdit.html#Syncfusion_WinForms_Input_SfDateTimeEdit_DateTimeIcon ) property in the SfDateTimeEdit control allows you to customize the calendar icon displayed in the drop-down button. By setting this property, you can replace the default icon with your own image, helping to match the design of your application.
108
103
109
- ### Change visibility of dropdown button
104
+ Note: The recommended size for the custom image is 16x16 pixels. If the image is larger than this size, it will be automatically resized to 16x16 pixels.
105
+
106
+ {% tabs %}
107
+
108
+ {% highlight C# %}
109
+
110
+ this.dateTimeEdit.DateTimeIcon = Image.FromFile(@"Images/calendar.png");
111
+
112
+ {% endhighlight %}
113
+
114
+ {% highlight VB %}
115
+
116
+ Me.dateTimeEdit.DateTimeIcon = Image.FromFile(@"Images/calendar.png");
117
+
118
+ {% endhighlight %}
119
+
120
+ {% endtabs %}
121
+
122
+ ![ Customize drop-down calendar appearance] ( appearance-images/CalendarIconCustomization.png )
123
+
124
+ ### Change visibility of drop-down button
110
125
111
126
The drop-down button in the SfDateTimeEdit allows you to open the pop-up calendar by using the mouse interaction. The visibility of drop-down button can be changed by the [ ShowDropDown] ( https://help.syncfusion.com/cr/windowsforms/Syncfusion.WinForms.Input.SfDateTimeEdit.html#Syncfusion_WinForms_Input_SfDateTimeEdit_ShowDropDown ) property.
112
127
113
128
{% tabs %}
114
129
115
130
{% highlight C# %}
116
131
117
- //Enable the DropDown Button
132
+ //Enable the DropDown Button
118
133
119
- this.dateTimeEdit.ShowDropDown = true;
134
+ this.dateTimeEdit.ShowDropDown = true;
120
135
121
- //Disable the DropDown Button
136
+ //Disable the DropDown Button
122
137
123
- this.dateTimeEdit.ShowDropDown = false;
138
+ this.dateTimeEdit.ShowDropDown = false;
124
139
125
140
{% endhighlight %}
126
141
127
142
{% highlight VB %}
128
143
129
- 'Enable the DropDown Button
144
+ 'Enable the DropDown Button
130
145
131
- Me.dateTimeEdit.ShowDropDown = true
146
+ Me.dateTimeEdit.ShowDropDown = true
132
147
133
- 'Disable the DropDown Button
148
+ 'Disable the DropDown Button
134
149
135
- Me.dateTimeEdit.ShowDropDown = false
150
+ Me.dateTimeEdit.ShowDropDown = false
136
151
137
152
{% endhighlight %}
138
153
@@ -155,29 +170,23 @@ The following code snippets illustrates the same.
155
170
156
171
{% highlight C# %}
157
172
158
- //Setting the UpDown Fore color
159
-
160
- this.dateTimeEdit.Style.UpDownForeColor = Color.HotPink;
161
-
162
- this.dateTimeEdit.Style.UpDownHoverForeColor = Color.Blue;
173
+ //Setting the UpDown Fore color
163
174
164
- this.dateTimeEdit.Style.UpDownBackColor = Color.LightGray;
165
-
166
- this.dateTimeEdit.Style.UpDownHoverBackColor = Color.Yellow;
175
+ this.dateTimeEdit.Style.UpDownForeColor = Color.HotPink;
176
+ this.dateTimeEdit.Style.UpDownHoverForeColor = Color.Blue;
177
+ this.dateTimeEdit.Style.UpDownBackColor = Color.LightGray;
178
+ this.dateTimeEdit.Style.UpDownHoverBackColor = Color.Yellow;
167
179
168
180
{% endhighlight %}
169
181
170
182
{% highlight VB %}
171
183
172
- 'Setting the UpDown Fore color
173
-
174
- Me.dateTimeEdit.Style.UpDownForeColor = Color.HotPink
175
-
176
- Me.dateTimeEdit.Style.UpDownHoverForeColor = Color.Blue
177
-
178
- Me.dateTimeEdit.Style.UpDownBackColor = Color.LightGray
184
+ 'Setting the UpDown Fore color
179
185
180
- Me.dateTimeEdit.Style.UpDownHoverBackColor = Color.Yellow
186
+ Me.dateTimeEdit.Style.UpDownForeColor = Color.HotPink
187
+ Me.dateTimeEdit.Style.UpDownHoverForeColor = Color.Blue
188
+ Me.dateTimeEdit.Style.UpDownBackColor = Color.LightGray
189
+ Me.dateTimeEdit.Style.UpDownHoverBackColor = Color.Yellow
181
190
182
191
{% endhighlight %}
183
192
@@ -193,25 +202,25 @@ The up-down allows you to change the value by increment or decrement of values o
193
202
194
203
{% highlight C# %}
195
204
196
- //Enable the UpDown Button
205
+ //Enable the UpDown Button
197
206
198
- this.dateTimeEdit.ShowUpDown = true;
207
+ this.dateTimeEdit.ShowUpDown = true;
199
208
200
- //Disable the UpDown Button
209
+ //Disable the UpDown Button
201
210
202
- this.dateTimeEdit.ShowUpDown = false;
211
+ this.dateTimeEdit.ShowUpDown = false;
203
212
204
213
{% endhighlight %}
205
214
206
215
{% highlight VB %}
207
216
208
- 'Enable the UpDown Button
217
+ 'Enable the UpDown Button
209
218
210
- Me.dateTimeEdit.ShowUpDown = true
219
+ Me.dateTimeEdit.ShowUpDown = true
211
220
212
- 'Disable the UpDown Button
221
+ 'Disable the UpDown Button
213
222
214
- Me.dateTimeEdit.ShowUpDown = false
223
+ Me.dateTimeEdit.ShowUpDown = false
215
224
216
225
{% endhighlight %}
217
226
@@ -227,13 +236,13 @@ The drop-down calendar of the SfDateTimeEdit can be obtained from the [MonthCale
227
236
228
237
{% highlight C# %}
229
238
230
- dateTimeEdit.MonthCalendar.ShowFooter = false;
239
+ dateTimeEdit.MonthCalendar.ShowFooter = false;
231
240
232
241
{% endhighlight %}
233
242
234
243
{% highlight VB %}
235
244
236
- dateTimeEdit.MonthCalendar.ShowFooter = false
245
+ dateTimeEdit.MonthCalendar.ShowFooter = false
237
246
238
247
{% endhighlight %}
239
248
@@ -249,21 +258,19 @@ The size of the drop-down calendar can be customized by using the [DropDownSize]
249
258
250
259
{% highlight C# %}
251
260
252
- //Setting DropDownSize
261
+ //Setting DropDownSize
253
262
254
- this.dateTimeEdit.DropDownSize = new Size(294, 293);
255
-
256
- this.dateTimeEdit.Width = 294;
263
+ this.dateTimeEdit.DropDownSize = new Size(294, 293);
264
+ this.dateTimeEdit.Width = 294;
257
265
258
266
{% endhighlight %}
259
267
260
268
{% highlight VB %}
261
269
262
- 'Setting DropDownSize
263
-
264
- Me.dateTimeEdit.DropDownSize = New Size(294, 293)
270
+ 'Setting DropDownSize
265
271
266
- Me.dateTimeEdit.Width = 294
272
+ Me.dateTimeEdit.DropDownSize = New Size(294, 293)
273
+ Me.dateTimeEdit.Width = 294
267
274
268
275
{% endhighlight %}
269
276
@@ -279,8 +286,9 @@ Week numbers can be displayed by setting [ShowWeekNumbers](https://help.syncfusi
279
286
280
287
{% highlight C# %}
281
288
282
- //Setting ShowWeekNumbers
283
- sfDateTimeEdit1.MonthCalendar.ShowWeekNumbers = true;
289
+ //Setting ShowWeekNumbers
290
+
291
+ sfDateTimeEdit1.MonthCalendar.ShowWeekNumbers = true;
284
292
285
293
{% endhighlight %}
286
294
@@ -312,9 +320,9 @@ Before apply theme to SfDateTimeEdit, required theme assembly should be loaded a
312
320
313
321
{% highlight C# %}
314
322
315
- using Syncfusion.WinForms.Controls;
323
+ using Syncfusion.WinForms.Controls;
316
324
317
- static class Program
325
+ static class Program
318
326
{
319
327
/// <summary>
320
328
/// The main entry point for the application.
@@ -333,9 +341,9 @@ using Syncfusion.WinForms.Controls;
333
341
334
342
{% highlight VB %}
335
343
336
- Imports Syncfusion.WinForms.Controls
344
+ Imports Syncfusion.WinForms.Controls
337
345
338
- Friend Module Program
346
+ Friend Module Program
339
347
''' <summary>
340
348
''' The main entry point for the application.
341
349
''' </summary>
@@ -363,17 +371,17 @@ This option helps to set the Office2016Colorful Theme.
363
371
364
372
{% highlight C# %}
365
373
366
- // Office2016Colorful
374
+ // Office2016Colorful
367
375
368
- this.dateTimeEdit.ThemeName = "Office2016Colorful";
376
+ this.dateTimeEdit.ThemeName = "Office2016Colorful";
369
377
370
378
{% endhighlight %}
371
379
372
380
{% highlight VB %}
373
381
374
- ' Office2016Colorful
382
+ ' Office2016Colorful
375
383
376
- Me.dateTimeEdit.ThemeName = "Office2016Colorful"
384
+ Me.dateTimeEdit.ThemeName = "Office2016Colorful"
377
385
378
386
{% endhighlight %}
379
387
@@ -389,17 +397,17 @@ This option helps to set the Office2016White Theme.
389
397
390
398
{% highlight C# %}
391
399
392
- // Office2016White
400
+ // Office2016White
393
401
394
- this.dateTimeEdit.ThemeName = "Office2016White";
402
+ this.dateTimeEdit.ThemeName = "Office2016White";
395
403
396
404
{% endhighlight %}
397
405
398
406
{% highlight VB %}
407
+
408
+ ' Office2016White
399
409
400
- ' Office2016White
401
-
402
- Me.dateTimeEdit.ThemeName = "Office2016White"
410
+ Me.dateTimeEdit.ThemeName = "Office2016White"
403
411
404
412
{% endhighlight %}
405
413
@@ -415,17 +423,17 @@ This option helps to set the Office2016DarkGray Theme.
415
423
416
424
{% highlight C# %}
417
425
418
- // Office2016DarkGray
426
+ // Office2016DarkGray
419
427
420
- this.dateTimeEdit.ThemeName = "Office2016DarkGray";
428
+ this.dateTimeEdit.ThemeName = "Office2016DarkGray";
421
429
422
430
{% endhighlight %}
423
431
424
432
{% highlight VB %}
425
433
426
- ' Office2016DarkGray
434
+ ' Office2016DarkGray
427
435
428
- Me.dateTimeEdit.ThemeName = "Office2016DarkGray"
436
+ Me.dateTimeEdit.ThemeName = "Office2016DarkGray"
429
437
430
438
{% endhighlight %}
431
439
@@ -441,17 +449,17 @@ This option helps to set the Office2016Black Theme.
441
449
442
450
{% highlight C# %}
443
451
444
- // Office2016Black
452
+ // Office2016Black
445
453
446
- this.dateTimeEdit.ThemeName = "Office2016Black";
454
+ this.dateTimeEdit.ThemeName = "Office2016Black";
447
455
448
456
{% endhighlight %}
449
457
450
458
{% highlight VB %}
451
459
452
- ' Office2016Black
460
+ ' Office2016Black
453
461
454
- Me.dateTimeEdit.ThemeName = "Office2016Black"
462
+ Me.dateTimeEdit.ThemeName = "Office2016Black"
455
463
456
464
{% endhighlight %}
457
465
0 commit comments