Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Calendar
  New Posts New Posts RSS Feed - Strange Problem
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Strange Problem

 Post Reply Post Reply
Author
Message
dneilsen View Drop Down
Newbie
Newbie


Joined: 18 April 2006
Location: Australia
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote dneilsen Quote  Post ReplyReply Direct Link To This Post Topic: Strange Problem
    Posted: 04 May 2006 at 10:26pm
I have encountered a strange occurance in the calendar control.  Not sure if it is something I have done or not.

Here is the piece of code I am using


        public void RefreshMonth()
        {
            addDebug("Running Refresh Display");
           
            //reset calendar formatting
            this.MonthView.WeeksCount = weeksInMonth(_CurrentDate);
            addDebug("-- Set display to "+weeksInMonth(_CurrentDate)+" weeks");
            addDebug("---- Confirm "+this.MonthView.WeeksCount+" weeks");
            addDebug("-- Redrawing control");
           
           
            //update all events
            addDebug("-- Removing all events");
            this.DataProvider.RemoveAllEvents();
                       
            CalendarDataProvider pCalendarData = this.DataProvider;
            pCalendarData.Create();

            addDebug("-- Creating events for "+this.ActiveView.DaysCount+" days");
            for(int i=0; i<this.ActiveView.DaysCount; i++)
            {
                CalendarViewDay cvd = this.ActiveView;
                addDebug("--- Checking "+cvd.Date.ToShortDateString());

                if(cvd.Date.Month != _CurrentDate.Month)
                    continue;

                int day = cvd.Date.Day;
                int index = day-1;
                double data = Convert.ToDouble(_dataStore[index]);
                addDebug("--- Adding event for day "+day+" - "+data+" hours");

                CalendarEvent ptrEvent = pCalendarData.CreateEvent();
                ptrEvent.StartTime = cvd.Date;
                DateTime dtNow = cvd.Date;
                ptrEvent.StartTime = dtNow;
                dtNow = dtNow.AddDays(1);
                ptrEvent.EndTime = dtNow;
                ptrEvent.Subject = Convert.ToString(data);
                ptrEvent.AllDayEvent = true;
                ptrEvent.Location = "Hrs";
                ptrEvent.Label = 0;
                pCalendarData.AddEvent(ptrEvent);
            }
            addDebug("-- Populating Data");
            pCalendarData.Save();
            this.Populate();               

            //do final update
            addDebug("-- Updating control");
            this.Update();
        }


Now this all works fine except in one situation.
Lets say the calendar is showing August 2005 (which has 5 week rows in the calendar) and I change to October 2005 (which has 6).

What occurs is that CalendarViewDay's on the 6th row of the calendar dont seem to return correctly in the following line.
CalendarViewDay cvd = this.ActiveView;
cvs.Date is always set to 30/12/1899

In my code this results in the two events that should be created on that 6th line, to not be created.

However, if I then run the exact same function again, immediately after the failed attempt, it works fine.


My question is...
I am quite new to these controls so it is quite possible I am not doing something correctly...   Is it my code (or something i have done) or is it a bug?



Back to Top
dneilsen View Drop Down
Newbie
Newbie


Joined: 18 April 2006
Location: Australia
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote dneilsen Quote  Post ReplyReply Direct Link To This Post Posted: 04 May 2006 at 10:28pm
oh yeah
I nearly forgot....
The debug output (from my addDebug command) is as follows


Running Refresh Display
-- Set display to 6 weeks
---- Confirm 6 weeks
-- Redrawing control
-- Removing all events
-- Creating events for 42 days
--- Checking 25/09/2005
--- Checking 26/09/2005
--- Checking 27/09/2005
--- Checking 28/09/2005
--- Checking 29/09/2005
--- Checking 30/09/2005
--- Checking 1/10/2005
--- Adding event for day 1 - 10 hours
--- Checking 2/10/2005
--- Adding event for day 2 - 10 hours
--- Checking 3/10/2005
--- Adding event for day 3 - 10 hours
--- Checking 4/10/2005
--- Adding event for day 4 - 10 hours
--- Checking 5/10/2005
--- Adding event for day 5 - 10 hours
--- Checking 6/10/2005
--- Adding event for day 6 - 10 hours
--- Checking 7/10/2005
--- Adding event for day 7 - 10 hours
--- Checking 8/10/2005
--- Adding event for day 8 - 10 hours
--- Checking 9/10/2005
--- Adding event for day 9 - 10 hours
--- Checking 10/10/2005
--- Adding event for day 10 - 10 hours
--- Checking 11/10/2005
--- Adding event for day 11 - 10 hours
--- Checking 12/10/2005
--- Adding event for day 12 - 10 hours
--- Checking 13/10/2005
--- Adding event for day 13 - 10 hours
--- Checking 14/10/2005
--- Adding event for day 14 - 10 hours
--- Checking 15/10/2005
--- Adding event for day 15 - 10 hours
--- Checking 16/10/2005
--- Adding event for day 16 - 10 hours
--- Checking 17/10/2005
--- Adding event for day 17 - 10 hours
--- Checking 18/10/2005
--- Adding event for day 18 - 10 hours
--- Checking 19/10/2005
--- Adding event for day 19 - 10 hours
--- Checking 20/10/2005
--- Adding event for day 20 - 10 hours
--- Checking 21/10/2005
--- Adding event for day 21 - 10 hours
--- Checking 22/10/2005
--- Adding event for day 22 - 10 hours
--- Checking 23/10/2005
--- Adding event for day 23 - 10 hours
--- Checking 24/10/2005
--- Adding event for day 24 - 10 hours
--- Checking 25/10/2005
--- Adding event for day 25 - 10 hours
--- Checking 26/10/2005
--- Adding event for day 26 - 10 hours
--- Checking 27/10/2005
--- Adding event for day 27 - 10 hours
--- Checking 28/10/2005
--- Adding event for day 28 - 10 hours
--- Checking 29/10/2005
--- Adding event for day 29 - 10 hours
--- Checking 30/12/1899
--- Checking 30/12/1899
--- Checking 30/12/1899
--- Checking 30/12/1899
--- Checking 30/12/1899
--- Checking 30/12/1899
--- Checking 30/12/1899
-- Populating Data
-- Updating control



Back to Top
sserge View Drop Down
Moderator Group
Moderator Group


Joined: 01 December 2004
Status: Offline
Points: 1297
Post Options Post Options   Thanks (0) Thanks(0)   Quote sserge Quote  Post ReplyReply Direct Link To This Post Posted: 06 May 2006 at 2:05pm
Quote
this.MonthView.WeeksCount = weeksInMonth(_CurrentDate);
 

When you change MonthView.WeeksCount - you have to call Populate method first to adjust calendar view days collection. (should be done before accesssing ActiveView members)
 
this.DataProvider.RemoveAllEvents();
this.Populate();

--
WBR,
Serge
Back to Top
dneilsen View Drop Down
Newbie
Newbie


Joined: 18 April 2006
Location: Australia
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote dneilsen Quote  Post ReplyReply Direct Link To This Post Posted: 07 May 2006 at 6:19pm
ahh sweet.
Thought it was something I had done (or had not done)
Thanks again sserge
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.141 seconds.