Use NodeXLControl in window form and set its properties

Nov 9, 2012 at 12:36 PM

Hi,

I am using nodeXl controls in wpf application for quite a month now and it works seamlessly in this enviroment.

But now we are planning to use it standard window application.

I have seen we can use nodexlControl  by setting ElementHost.child property during runtime.

nodeXLControl1 = new NodeXLControl();         
elementHost1.Child = nodeXLControl1;

But NodeXLcontrol is not visible to me on window form nither in toolbar vs 2008.

How can i set the properties for nodeXlControl1 eg. VertexClick event, SelectionChange event, adding items in context menu ...

Coordinator
Nov 9, 2012 at 6:27 PM
Edited Nov 9, 2012 at 6:28 PM

Rajeev:

The Visual Studio designer won't let you add a WPF control like NodeXLControl to a Windows Forms form.  (At least, I've never figured out a way to get Visual Studio to do that.)  It will let you add an ElementHost to the form, but you have to "manually" create the WPF control in code and add it to the form as the child of the ElementHost.

Setting the NodeXLControl's properties in code is trivial.  For example:

    nodeXLControl1.ShowVertexToolTips = true;

To handle the NodeXLControl's events in code, you use standard C# event handling syntax:

    nodeXLControl1.SelectionChanged += new System.EventHandler(nodeXLControl1_SelectionChanged);

To add a context menu to the NodeXLControl, you would handle its GraphMouseUp event and show a ContextMenuStrip in the event handler.

-- Tony