Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
295
context menu Position in ultragrid
posted

Hello,

I am trying to display context menu only when a user clicks on any row in ultragrid. I am using the code below.

 

UIElement aUIElement =

           

this.ultraGridSearchList.DisplayLayout.UIElement.ElementFromPoint(new Point(e.X, e.Y));

           

UltraGridRow aRow = null;

            Infragistics.Win.UltraWinGrid.

ColumnHeader mouseupColumnHead = null;

           

Point p = PointToScreen(MousePosition);

         

           

if (aUIElement != null)

            {

               

///Declare and retrieve a reference to the row

                aRow = (

UltraGridRow)aUIElement.GetContext(typeof(UltraGridRow));

                mouseupColumnHead = (Infragistics.Win.UltraWinGrid.

ColumnHeader)aUIElement.GetContext(typeof(Infragistics.Win.UltraWinGrid.ColumnHeader), true);

            }

           

if (e.Button == System.Windows.Forms.MouseButtons.Right && aRow != null && mouseupColumnHead == null)

            {

                contextMenuStripPreviewPane.Show(PointToScreen(p));         

                return;

            }

 

But my context menu is not appearing at exact mouse position when clicked. Is there any seperate why to try out.

I have tried PointToClient as well.

 

Parents
No Data
Reply
  • 71886
    Offline posted

    Hello rooma,

    Could you try to use just 'MousePosition' for the p variable and not PointToScreen(MousePosition). Also pass PointToClient(p) to the Show() method and let me know of the result satisfies your needs.

Children