+ Reply to Thread
Results 1 to 3 of 3

Context-sensitive Actions pane

  1. #1
    JanF
    Guest

    Context-sensitive Actions pane

    I posted this on the VSTO forum, and they suggested I also post here.

    I have an Excel workbook that's part of a VSTO solution. It contains two
    named Ranges: OrderDate and ShipDate. When I select either of these cells, I
    want the Actions pane to display a user control that contains a label and a
    DateTimePicker control. I want the user control to show up in the Actions
    pane only when one of these cells is selected, so I have code on the ranges'
    Selected and Deselected event handlers to add or remove the control (I'm not
    including the code but you can see it in my original post:
    http://forums.microsoft.com/MSDN/Sho...teID=1&mode=1).

    The solution works fine when I put my cursor on OrderDate and then move to
    ShipDate. It also works fine when I move from any other cell to either
    OrderDate or ShipDate.

    The solution does NOT work when I move from ShipDate to OrderDate. The
    control is removed but not added. I added some message boxes and it looks
    like the events are firing in the wrong order: The OrderDate_Selected event
    fires BEFORE the ShipDate_Deselected event.

    (In the OrderDate to ShipDate scenario the events fire as I would expect,
    OrderDate_Deselected and then ShipDate_Selected.)

    Is this behavior by design? If so why is it that way? (This is a teaching
    sample so I'd like to be able to explain why I need whatever workaround I
    come up with).

    Just so you know, there's nothing special about the workbook. I was able to
    recreate on a completely vanilla new workbook/project.


  2. #2
    Valued Forum Contributor tony h's Avatar
    Join Date
    03-14-2005
    Location
    England: London and Lincolnshire
    Posts
    1,187
    I have not looked at your code in any detail but I would not use message boxes to track the order of selected/deselected. Use something passive like a debug.print or print to a log file. As the Messagebox takes the focus it may itself change the selected deselectd effect.

    regards

    PS may look t the code tomorrow

  3. #3
    JanF
    Guest

    Re: Context-sensitive Actions pane

    Thanks, Tony; no need to investigate further. The VSTO team says that the
    events are nondeterministic. I just needed to find a way to get around that
    in the code, and they pointed me in the right direction there as well.

    "tony h" wrote:

    >
    > I have not looked at your code in any detail but I would not use message
    > boxes to track the order of selected/deselected. Use something passive
    > like a debug.print or print to a log file. As the Messagebox takes the
    > focus it may itself change the selected deselectd effect.
    >
    > regards
    >
    > PS may look t the code tomorrow
    >
    >
    > --
    > tony h
    > ------------------------------------------------------------------------
    > tony h's Profile: http://www.excelforum.com/member.php...o&userid=21074
    > View this thread: http://www.excelforum.com/showthread...hreadid=520769
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1