Hi,
I have attached an event handler to an XamGrid, when the user clicks on one of the options I want to figure out if the mouse was over a cell and if so which cell.
<ig:XamGrid> <ig:ContextMenuService.Manager> <ig:ContextMenuManager > <ig:ContextMenuManager.ContextMenu> <ig:XamContextMenu> <ig:XamMenuItem Header="Item 1" Click="XamMenuItem_Click" /> </ig:XamContextMenu> </ig:ContextMenuManager.ContextMenu> </ig:ContextMenuManager> </ig:ContextMenuService.Manager> </ig:XamGrid>
In the event handler :
private void XamMenuItem_Click(object sender, EventArgs e) { }
How can I figure out if the click was above a cell?
Thanks,
Hello Sekhar,
The blog has been updated to include the sample source code.
Please let me know if you have any questions.
Sincerely,
Valerie
Developer Support Engineer Infragisticswww.infragistics.com/support
Code sample is not downloadable. Could you please let us know what is correct location to download the sample.
If you want something quick and dirty without all the code provided by the link given, just add a handler for the XamContextmenu.Opening event and capture the clicked cell control.
CellControl clickedCellControl;
private void XamContextMenu_Opening(object sender, Infragistics.Controls.Menus.OpeningEventArgs e)
{
//get the first item
clickedCellControl = e.GetClickedElements<CellControl>().FirstOrDefault();
}
private void XamMenuItem_Click(object sender, EventArgs e)
if (clickedCellControl != null)
MessageBox.Show(clickedCellControl.Cell.Value.ToString());
Hello yashikal,
Do you have any other questions on this matter?
Sincerely,ValerieDeveloper Support Engineer Infragisticswww.infragistics.com/support
In the example provided shows how to get it's cell after right clicking and opening the context menu: http://blogs.infragistics.com/blogs/devin_rader/archive/2011/04/15/extending-xamgrid-with-a-right-click-context-menu.aspx.