Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.
Problem with Adding to TimeBlockList
I am encountering two issues with adding 'TimeBlocks' to the Schedule Control:
1. Adding random time blocks to the list has caused a 'OpenInsight' is not responding message fairly frequently. Unfortunately, I don't seem to be able to cause this to happen, so I can't report a 'path' to creating this problem.
2. I am adding time blocks to the schedule by using the 'OnScheduleClick' event and then calling a dialog box to collect the information necessary to add to the 'TimeBlockList' property. This is working, to a point. If you add a time block to an entity to the left of an entity that already has a time block, SOMETIMES the schedule will pop duplicate time blocks from other columns into the column to which you are adding a time block and duplicates into other columns as well. I have inspected the 'TimeBlockList' variable that I am maintaining and do not see duplicate instances in that variable. Also, if I close the schedule and then reopen it (which then reads the TimeBlockList variable from a file in which I am maintaining it), the duplicate time blocks are gone.
1. Adding random time blocks to the list has caused a 'OpenInsight' is not responding message fairly frequently. Unfortunately, I don't seem to be able to cause this to happen, so I can't report a 'path' to creating this problem.
2. I am adding time blocks to the schedule by using the 'OnScheduleClick' event and then calling a dialog box to collect the information necessary to add to the 'TimeBlockList' property. This is working, to a point. If you add a time block to an entity to the left of an entity that already has a time block, SOMETIMES the schedule will pop duplicate time blocks from other columns into the column to which you are adding a time block and duplicates into other columns as well. I have inspected the 'TimeBlockList' variable that I am maintaining and do not see duplicate instances in that variable. Also, if I close the schedule and then reopen it (which then reads the TimeBlockList variable from a file in which I am maintaining it), the duplicate time blocks are gone.
Comments
Are you always using the TimeBlockList property when adding new time blocks? Have you tried using the AddTimeBlocks method instead? You may have uncovered a problem with the TimeBlockList property but your description of what you are doing suggests to me that the AddTimeBlocks method would suit your needs better.
I am not expecting you to rewrite your process. If the property is at fault then we will work to address it. However, if you need a workaround in the meantime then perhaps the AddTimeBlocks method will work.
Having said that, there is a best practice approach to using some of the Schedule control's properties that support multiple data points:
If I understand you correctly, you are simply using the TimeBlockList property to handle both types of operations. While the TimeBlockList property should work just fine, it is possible we are seeing a bug when the property is being reset this way.
Quite often these kind of bugs are difficult for us to discover because they tend to only occur under unique circumstances. In these cases we need to lean on our customers for additional help. This leads me to a couple more questions:
We believe both the intermittent OpenInsight crashes and the odd visual anomalies (i.e., time blocks would be duplicated and appear under different entities) were related to the same issue. Specifically, the Schedule control did not properly handle the setting of the same time block value multiple times. This was never discovered during our original tests because (as noted above) the best practice is to use the TimeBlockList property to setup the initial time blocks on the Schedule (e.g., those which were pre-defined in the database) and then to use the AddTimeBlock method to add new time blocks. In theory, no time block would be added to the Schedule control more than once in a single run-time session. However, since Jan was using the TimeBlockList property to add new time blocks, this also re-added pre-existing time blocks (out of necessity, or otherwise they would have been removed.) This exposed a bug in the Schedule control which has now been fixed and will be included in the next release.
During the offline testing session with Jan, she also discovered another issue: The AfterNewApptDrop event would fire after the OnScheduleClick event. This was a problem because the former event is used to create new appointments and the latter event is used to create new time blocks. The intent was to give the user a way to create one or the other using a familiar technique (mouse left click), but since the AfterNewApptDrop event requires a drag motion to distinguish itself, this seemed like a safe design approach.
This exposed a natural conflict that occurs with certain events, similar to how single-click and double-click events can also interfere with one another. Consider the following gotchas:
Double whammy! The moral of the story is that trapping the left click of a button and trapping the left click and drag of a button on the same control to provide different features is not a safe or recommended design choice. In Jan's case, she switched the time block logic to the right click.
This adventure did yield some minor treasure. I proposed to add the detection of the Ctrl, Alt, and Shift keys to the AfterNewApptDrop event in order to provide her with more options (e.g., Left Click Drag for new appointments, Shift+Left Click Drag for new time blocks). As we dug into the code to add this support we discovered that it was already there! It just never got documented. Using the magic of the wiki, the AfterNewApptDrop event was quickly updated to reflect these arguments.