Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Calendar
  New Posts New Posts RSS Feed - DatePicker select several range of dates via code
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

DatePicker select several range of dates via code

 Post Reply Post Reply
Author
Message
pjsde View Drop Down
Newbie
Newbie
Avatar

Joined: 20 May 2007
Location: Portugal
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote pjsde Quote  Post ReplyReply Direct Link To This Post Topic: DatePicker select several range of dates via code
    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
Back to Top
apuhjee View Drop Down
Senior Member
Senior Member
Avatar

Joined: 02 September 2005
Location: United States
Status: Offline
Points: 130
Post Options Post Options   Thanks (0) Thanks(0)   Quote apuhjee Quote  Post ReplyReply Direct Link To This Post 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));

    }

}

 

 

Back to Top
pjsde View Drop Down
Newbie
Newbie
Avatar

Joined: 20 May 2007
Location: Portugal
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote pjsde Quote  Post ReplyReply Direct Link To This Post Posted: 20 June 2007 at 3:41pm

Now its working.

 
Thanks
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.219 seconds.