N
Neville Lang
To Microsoft CF team and list,
I have previously posted information on this topic but I now want to open
another thread here after I have worked on this problem for a few days now
and want to share some information.
I have CF 1.0 SP2 and have been trying to get a ContextMenu working without
success. I keep getting a System.ArgumentException error.
What I am trying to achieve is to have a ToolBarButton set for a PushButton
style raise a ContextMenu when tapped. This part works as expected. As
background, I chose to use a ToolBarButton with PushButton style and a
separate ContextMenu instead of a ToolBarButton with the DropDownMenu style
set because I have found that for some Pocket PCs running PPC 2002 this
latter combination causes the Pocket PC to freeze after a couple of taps on
the menu. Having a ToolBarButton set as a PushButton and using a separate
ContextMenu overcomes the freeze problem on those Pocket PCs.
However, I also have various conditions in my app where I want to display
different menu items in the ContextMenu. When such a condition is
encountered in my app, I call a method and simply run
ContextMenu.MenuItems.Clear() and then begin using the Add() method to add
the new set of menu items. Theoretically, this should work every time, but
it does not.
I have now proven beyond doubt that a second call to my method that first
"clears" the MenuItems collection then "adds" the new ones will crash the
system IF the ContextMenu has not yet been displayed.
After much testing, it seems that the ContextMenu needs to be displayed
first each time after you Clear() then Add() a new set of menu items to
avoid the error message.
Displaying the context menu at the wrong time so a user can dismiss it just
to rebuild the next set of menu items is pretty ugly. This is the only
workaround I can find.
Does anybody know of a way to programmatically dismiss the ContextMenu in
order to provide this workaround?
For anyone interested, I can send you my VS .NET 2003 solution files that
will demonstrate this problem.
Does anyone have any other method of building different menu items for a
ContextMenu?
Does anyone know if CF 1.0 SP3 Beta or even CF 2.0 Beta fixes this problem?
Regards,
Neville Lang
I have previously posted information on this topic but I now want to open
another thread here after I have worked on this problem for a few days now
and want to share some information.
I have CF 1.0 SP2 and have been trying to get a ContextMenu working without
success. I keep getting a System.ArgumentException error.
What I am trying to achieve is to have a ToolBarButton set for a PushButton
style raise a ContextMenu when tapped. This part works as expected. As
background, I chose to use a ToolBarButton with PushButton style and a
separate ContextMenu instead of a ToolBarButton with the DropDownMenu style
set because I have found that for some Pocket PCs running PPC 2002 this
latter combination causes the Pocket PC to freeze after a couple of taps on
the menu. Having a ToolBarButton set as a PushButton and using a separate
ContextMenu overcomes the freeze problem on those Pocket PCs.
However, I also have various conditions in my app where I want to display
different menu items in the ContextMenu. When such a condition is
encountered in my app, I call a method and simply run
ContextMenu.MenuItems.Clear() and then begin using the Add() method to add
the new set of menu items. Theoretically, this should work every time, but
it does not.
I have now proven beyond doubt that a second call to my method that first
"clears" the MenuItems collection then "adds" the new ones will crash the
system IF the ContextMenu has not yet been displayed.
After much testing, it seems that the ContextMenu needs to be displayed
first each time after you Clear() then Add() a new set of menu items to
avoid the error message.
Displaying the context menu at the wrong time so a user can dismiss it just
to rebuild the next set of menu items is pretty ugly. This is the only
workaround I can find.
Does anybody know of a way to programmatically dismiss the ContextMenu in
order to provide this workaround?
For anyone interested, I can send you my VS .NET 2003 solution files that
will demonstrate this problem.
Does anyone have any other method of building different menu items for a
ContextMenu?
Does anyone know if CF 1.0 SP3 Beta or even CF 2.0 Beta fixes this problem?
Regards,
Neville Lang