Advanced reporting
and data visualization components for .NET
LIVE CHAT Welcome, guest

 





Change Context Menu
Display Posts for:
Invert
Yusuf Incekara 09/24/2012 04:28
Change Context Menu

Is it possible to somehow cancel report designer's own right click context menu and instead display my own ?
I am tracing rd1_DesignerMouseDown event and set handled=true but it doesn't work.

private void rd1_DesignerMouseDown(object sender, DesignerMouseEventArgs args)
{
if (args.MouseMode == "SelectMouseMode" && args.Button == MouseButtons.Right )
{
args.Handled = true;
return;
}

}
Maxim Edapin 10/10/2012 06:16
Change Context Menu

Hello Yusuf!

There is a property MouseModeContextMenuStrip in ReportDesigner class, that represents context menu. Unfortunately it is read only.
As workaround you can use following code:

Code:
FieldInfo fieldinfo = typeof(ReportDesigner).GetField("mouseModeContextMenuStrip", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
ContextMenuStrip menu = new System.Windows.Forms.ContextMenuStrip();
menu.Items.Add("1");
menu.Items.Add("2");
fieldinfo.SetValue(designer, menu);


Best regards,
Maxim Edapin
Perpetuum Software Team
Yusuf Incekara 10/17/2012 03:11
Change Context Menu

Hello Maxim. Unfortunately it doesn't help.
I don't want to add some items to existing popup menu. I instead want to use my own. Totally different one. We are using infragistics components for such issues. In this case there is no way me to use infragistics popup menu.
Would you please add this as a request or is there any place that we can post our requests for new version ?

Quote:
Hello Yusuf!

There is a property MouseModeContextMenuStrip in ReportDesigner class, that represents context menu. Unfortunately it is read only.
As workaround you can use following code:

Code:
FieldInfo fieldinfo = typeof(ReportDesigner).GetField("mouseModeContextMenuStrip", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
ContextMenuStrip menu = new System.Windows.Forms.ContextMenuStrip();
menu.Items.Add("1");
menu.Items.Add("2");
fieldinfo.SetValue(designer, menu);


Best regards,
Maxim Edapin
Perpetuum Software Team
Yusuf Incekara 10/17/2012 03:45
Change Context Menu

FieldInfo fieldinfo = typeof(ReportDesigner).GetField("mouseModeContextMenuStrip", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
fieldinfo.SetValue(rd1, null);
tbmForm.SetContextMenuUltra(rd1, "popForm"); //set infragistics ultratoolbarsmanager popup menu to report designer

This might work perfectly unless if we might set context menu to null ... Then we may set our own.
But this is not working also.
Dmitry Plutalov 12/10/2012 02:27
Change Context Menu

Hello Yusuf,

As we can see, infragistics function SetContextMenuUltra requires direct link to the component you need to set context menu for. Unfortunately, it is not possible for us to make it public due to the purposes of encapsulation.

But you may still try reflection to get it:
FieldInfo fieldinfo = typeof(ReportDesigner).GetField("paintBox", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
var paintBox = fieldinfo.GetValue(designer, menu) as Control;
tbmForm.SetContextMenuUltra(paintBox, "popForm");

If it still doesn't work for you, you need to contact infragistics to ask them to tell you what exactly this function does, so we could find what do we need to do to make it work.

Best Regards,
Dmitry Plutalov
Perpetuum Software Team
Yusuf Incekara 12/10/2012 03:35
Change Context Menu

Hello Dmitry,
This not a big deal for me to set infragistics popup menu component onto your design component. It would be just enough if i can set null to existing popup menu. I already can set infragistics to your designer component and add my own items and run them. The problem is there are 2 popup menu on the form now. I should be able to kill the other one.
Dmitry Plutalov 12/12/2012 05:31
Change Context Menu

Hello Yusuf,

We plan to introduce ability to set context menu via ReportDesigner's MouseModeContextMenu. It should support setting menu to null (That should disable menu for the report designer). This feature should be available in the next version of SharpShooter Reports that is planned to go out in the second part of December.

Best Regards,
Dmitry Plutalov
Perpetuum Software Team