This is a migrated thread and some comments may be shown as answers.

doubled up right click menu

3 Answers 93 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Justin
Top achievements
Rank 1
Justin asked on 31 Jan 2008, 06:03 PM
When I add a right click menu to my grid via the ContextMenuStrip property, it works fine. Except when I right click on the filter bar. Then I get both menus.

Image : http://tinyimg.us/i/cqs1201802556v.jpg

Anyone have a fix for this? Other than waiting for the next release?

3 Answers, 1 is accepted

Sort by
0
Accepted
Jack
Telerik team
answered on 01 Feb 2008, 01:51 PM
Hello Justin,

Thank you for writing us.

Currently you can fix this issue by inheriting the RadGridView and overriding the OnMouseDown method. We will add API that enables context menu customization in our upcoming release Q1 2008.

Consider the code snippet below:

    public class MyGridView : RadGridView 
    { 
        public override string ThemeClassName 
        { 
            get 
            { 
                return typeof(RadGridView).FullName; 
            } 
            set 
            { 
            } 
        } 
 
        protected override void OnMouseDown(MouseEventArgs e) 
        { 
            if (e.Button == MouseButtons.Right) 
            { 
                RadElement element = this.GetElementAtPoint(e.Location); 
                if (element is GridHeaderCellElement) 
                { 
                    return
                } 
            } 
            base.OnMouseDown(e); 
        } 
    } 


Let us know if you have other questions.

Best wishes,
Jack
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Justin
Top achievements
Rank 1
answered on 15 Feb 2008, 01:29 AM
I've done this and it works most of the time, but occasionally when resizing a column I'll get a NullRef when I call base.OnMouseDown. I'm using Q3 2007 SP 1. Here's the stack trace: 

 

at Telerik.WinControls.UI.GridHeaderRowElement.OnMouseDown(MouseEventArgs e)  
 
at Telerik.WinControls.RadElement.OnCLREventsRise(RoutedEventArgs args)  
 
at Telerik.WinControls.RadElement.OnBubbleEvent(RadElement sender, RoutedEventArgs args)  
 
at Telerik.WinControls.RadItem.OnBubbleEvent(RadElement sender, RoutedEventArgs args)  
 
at Telerik.WinControls.RadElement.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)  
 
at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)  
 
at Telerik.WinControls.RadElement.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)  
 
at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)  
 
at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args)  
 
at Telerik.WinControls.RadElement.DoMouseDown(MouseEventArgs e)  
 
at Telerik.WinControls.RadElement.CallDoMouseDown(MouseEventArgs e)  
 
at Telerik.WinControls.RadControl.OnMouseDown(MouseEventArgs e)  
 
at Telerik.WinControls.UI.RadGridView.OnMouseDown(MouseEventArgs e)  
 
at Integra.EPC.RadGridViewFixed.OnMouseDown(MouseEventArgs e) in C:\Inetpub\wwwroot\EPC2\V1.0\EPC\EPC\Code Files\RadGridViewFixed.cs:line 74  
 
at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)  
 
at System.Windows.Forms.Control.WndProc(Message& m)  
 
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)  
 
at Telerik.WinControls.RadControl.WndProc(Message& m)  
 
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)  
 
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)  
 
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)  
 
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)  
 
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)  
 
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)  
 
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)  
 
at System.Windows.Forms.Application.Run(Form mainForm)  
 
at Integra.EPC.Program.RunMainForm() in C:\Inetpub\wwwroot\EPC2\V1.0\EPC\EPC\Code Files\Program.cs:line 99  
 
at Integra.EPC.Program.Main(String[] args) in C:\Inetpub\wwwroot\EPC2\V1.0\EPC\EPC\Code Files\Program.cs:line 46 

I even tried this:
  protected override void OnMouseDown(MouseEventArgs e)  
        {  
            base.OnMouseDown(e);  
      }  
 

And I still get the null reference exception. But I have to have this override in because the SP1 didn't address the double menu issue AFAIK.


0
Jack
Telerik team
answered on 15 Feb 2008, 09:33 AM
Hello Justin,

Thank you for this information.

Unfortunately, we could not reproduce this issue. Could you please, give us more details when exactly this exception is thrown. Sending us a sample application, will help us address any potential issue faster. For the time being you can work around this issue by catching the exception.

Do not hesitate to write us if you need further assistance.

Kind regards,
Jack
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
GridView
Asked by
Justin
Top achievements
Rank 1
Answers by
Jack
Telerik team
Justin
Top achievements
Rank 1
Share this question
or