Context menu location change

Hi, I am using Essential Suite 2.0.5.1 I am having a context menu associated with the Syncfusion.Windows.Forms.Grid.GridControl. The GridControl has multiple rows and columns, I can select a cell by left click on mouse, and if I right click there then able to see the context menu on selected cell (current cell). However, if I right click somewhere outside the cell (but with in the Grid Control) then the context menu displayed on location of mouse cursor. How can I show the context menu on selected cell (current cell) instead of on cursor position? Is there any way to change the location of the context menu in either ContextMenu_PopUp event or other method? Thanks in advance Dhans

6 Replies

AD Administrator Syncfusion Team December 2, 2005 01:06 PM UTC

Here is a little sample that positions a context menu (and the mouse cursor) in the middle of the current cell if you right click outside it. It also sets the contextmenu in the middle of a selected range of cells if you right click out side of the selection. Maybe something like this will work for you. http://www.syncfusion.com/Support/user/uploads/GC_ContextMenu_60da496f.zip


AD Administrator Syncfusion Team December 8, 2005 09:04 AM UTC

Clay, Thanks for that reply. Now, my requirement is, change the current cell to mouse cursor position when i right click inside the grid.


ST stanleyj Syncfusion Team December 8, 2005 10:11 AM UTC

Hi Dhans, You can move the current cell by getting the respective row, column of the cursor position by calling the PointToRowCol function. Here is the modified sample and the necessary codes are below. this.gridControl1.PointToRowCol(pt, out row, out col); this.gridControl1.CurrentCell.MoveTo(row, col); Regards, Stanley


AD Administrator Syncfusion Team December 8, 2005 10:30 AM UTC

Thanks Stanley, Already I have selected multiple cells, Then If I try to move the CurrentCell then the selections cleared. How to I retain the Selections of the GridControl?


ST stanleyj Syncfusion Team December 8, 2005 11:53 AM UTC

Hi Dhans, How are the selections getting cleared? The selections are not cleared when moving with arrow keys or with right mouse click. Regards, Stanley


AD Administrator Syncfusion Team December 8, 2005 12:40 PM UTC

Thanks Stanley, Now its works fine for me.

Loader.
Up arrow icon