How to create new custom form/dialog in Ribbon?

Nov 29, 2011 at 2:16 AM


Do you have any pointers or explanation as to how I could create a new Form/Dialog to pop up from Ribbon.cs?  For example, much like GraphMetricsDialog.cs eventually opens, gathers user input and fires off subsequent actions after one clicks the "Graph Metric" button, how could I go about doing the same for a new, custom button?  I know this is not a C#/Visual Studio forum, but it appears many of the classes for such things have been written internally.  Do I have to use the existing code (if so, how?) or is there a simpler way to do something that, in the end, will be simple?




Nov 29, 2011 at 5:14 AM
Edited Nov 29, 2011 at 5:15 AM


The sequence for adding a custom button to the NodeXL ribbon and handling its Click event is straightforward:

1. Open Ribbon.cs in the Visual Studio designer.

2. Open the Visual Studio Toolbox (View, Toolbox).

3. From the Office Ribbon Controls section of the Toolbox, drag a Button to the ribbon in the designer.

4. In the designer, double-click the new Button.

5. Fill in the NewButton_Click() event handler that Visual Studio creates for you.

If you want a custom dialog box to pop up, you have to create a new Form-derived class for the dialog box, then call Form.ShowDialog() from your event handler to show it.

I know of no simpler way to do this.

-- Tony

Dec 6, 2011 at 12:53 AM

Thanks Tony.  I wasn't sure if I had to use the FormPlus class or not.  Realized I don't.  Thanks!

Dec 6, 2011 at 12:56 AM

Right.  That's just the base class that NodeXL uses for convenience, but you are free to create any kind of dialog that works for you.

-- Tony