How to create new custom form/dialog in Ribbon?

Nov 29, 2011 at 1:16 AM

Hi,

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?

 

Thanks,

Nick

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

Nick:

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 5, 2011 at 11:53 PM

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

Dec 5, 2011 at 11:56 PM

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