DatePicker select several range of dates via code |
Post Reply |
Author | |
pjsde
Newbie Joined: 20 May 2007 Location: Portugal Status: Offline Points: 4 |
Post Options
Thanks(0)
Posted: 20 May 2007 at 11:18am |
Hello, I'm trying to select several range of dates in the DatePicker control via code, but it doesnt work. wend i use de selectrange( datemin, datemax) for all tha range of dates only the last block of date is selected. The AllowNoncontinuousSelection property is set to True.
Please, how can i add mor than 1 block of dates via code in the DatePicker Control.
Thanks
|
|
apuhjee
Senior Member Joined: 02 September 2005 Location: United States Status: Offline Points: 130 |
Post Options
Thanks(0)
|
This is a really late reply, but here it is anyways.
It appears from the docs that DatePicker.Select() can be used to create multiple blocks, but DatePicker.SelectRange() will blow away what you already have selected! Seems a bit inconsistent.
You can get around this with a few lines of code.
Cheers ~ jp
DateTime min1 = DateTime.Now; DateTime max1 = DateTime.Now.Add(new TimeSpan(6, 0, 0, 0)); DateTime min2 = DateTime.Now.Add(new TimeSpan(14, 0, 0, 0)); DateTime max2 = DateTime.Now.Add(new TimeSpan(20, 0, 0, 0)); selectRange(min1, max1); selectRange(min2, max2); private void selectRange(DateTime min, DateTime max) { //TODO: Assert min is less than max DateTime selDay = min; while (selDay <= max) datePicker.Select(selDay); selDay = selDay.Add(new TimeSpan(1, 0, 0, 0)); } } |
|
pjsde
Newbie Joined: 20 May 2007 Location: Portugal Status: Offline Points: 4 |
Post Options
Thanks(0)
|
Now its working. Thanks
|
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |