Print Page | Close Window

DatePicker select several range of dates via code

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Calendar
Forum Description: Topics Related to Codejock Calendar
URL: http://forum.codejock.com/forum_posts.asp?TID=7187
Printed Date: 27 November 2024 at 12:37am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: DatePicker select several range of dates via code
Posted By: pjsde
Subject: DatePicker select several range of dates via code
Date 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



Replies:
Posted By: apuhjee
Date Posted: 19 June 2007 at 9:25pm
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));

    }

}

 

 



Posted By: pjsde
Date Posted: 20 June 2007 at 3:41pm

Now its working.

 
Thanks



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net