Forum Discussion

PeterMitcham's avatar
Occasional Contributor
9 years ago

ContextMenuStrip - testing associated image

Hi   I have a ContextMenuStrip that contains items that consist of both image and text (see attached PNG).   The test needs to confirm whether the item in the menu is ticked or not and action acc...
  • PeterMitcham's avatar
    9 years ago

    Yes, I have access to developers and have spoken with them since the first post.


    The contextmenu contents when selected\deselected alter the visible structure of a grid. A hashtable is used to store the contents of the contextmenu and the hashtable is associated to the grid container object.


    I have managed to find a solution (other than testing pixels, however, unfortunately it is also fairly complicated.)


    Each Contextmenustrip content is derived from an associated hashtable, which in turn is populated from the current visible content within the associated grid (the contextmenu content when selected\deselected alters the visible structure of a grid)


    The associated hashtable will only contain the currently selected contextmenustrip content but it will retain the original position within the menu.


    An example of what i am saying is this


    If the menu contains 4 items and only 3 are selected (items 1, 3, 4), the associated hashtable will contain the following.






    Even though 2 exists in the contextmenu, because it is not selected it does not appear in the associated hashtable.


    The solution I have created enumerates through the hashtable checking if the item I need to select\deselect exists or not.


    1) I  check the state of the hashtable prior to performing my action on the contextmenustrip ( the contextmenustrio does not need to be visible to do this).

    2) Confirm the state and act accordingly (if its already selected, do nothing, otherwise select it)

    3) Where the contextmenustrip has been updated then I validate the hashtable contents post selection.