C1 Community
ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

question about multiple C1ContextMenus

rated by 0 users
This post has 1 Reply | 2 Followers

Not Ranked
Posts 4
donovanh Posted: Mon, Jun 1 2009 9:02 PM

I am developing an application that uses several C1PictureBox controls. Each PictureBox should have the same set of commands available from the context menu, which specify various things to do with the image in that particular PictureBox. It seems logical that I could create C1ContextMenus that are identical except for their names and attach them to the various PictureBoxes to avoid recreating every C1Command separately for each PictureBox. However, if I understand the documentation correctly, the event handlers would be responding to an event of the C1Command, which would mean the sender was the same no matter which ContextMenu containing that C1Command was clicked. Thus, I'm not sure how I can get the event handler to figure out which PictureBox's context menu was clicked, and hence which image it should be operating on. Am I missing a good way to let the event handler know which C1ContextMenu contained the C1Command that was clicked? Or am I stuck writing separate C1Commands for each PictureBox's context menu?  

I thank you in advance for any help you can offer, and I appreciate your forbearance if I've asked a dumb newbie question.

Not Ranked
Posts 1

Hi,

In order to find which PictureBox's context menu has been clicked, SourceControl property of C1ContextMenu can be used. The property has been added in C1Command build 2.0.20093.19441, available at http://prerelease.componentone.com/. It is not necessary to create separate C1ContextMenus for separate PictureBoxes. A single C1ContextMenu with a C1Command item can be set on every PictureBox and in the C1Command_Click event, "c1ContextMenu1.SourceControl.Name" can be used to determine which PictureBox has been clicked.

Please find attached Sample_PictureBox which performs this behavior. Hope this helps.

 Regards,

 Shilpa

Page 1 of 1 (2 items) | RSS
Contact ComponentOne: 1.800.858.2739 ©1987-2010 ComponentOne LLC All Rights Reserved.