Problem adding multiple buttons to custom toolbar


Author
Message
Eric Sweet
Eric Sweet
Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)
Group: Forum Members
Posts: 14, Visits: 1
Hi,

I've used the code from the sample app to add custom menu items, overload the functionality of existing buttons and add a single toolbar and button without any problems, but I am having trouble with adding more than one button to a custom toolbar. I always end up with just one button, and no errors. Can you provide any assistance with the code from the sample app for adding multiple buttons?

Thanks
Eric
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

Hi Eric,

Here is the requested code sample that adds two custom menu items with hosted button:

NButton btn1 = new NButton();
btn1.Text =
"Button 1";

NControlHostCommand controlHost1 = new NControlHostCommand();
controlHost1.SetControl(btn1);

nDockingToolbar1.Commands.Add(controlHost1);

NButton btn2 = new NButton();
btn2.Text = "Button 2";

NControlHostCommand controlHost2 = new NControlHostCommand();
controlHost2.SetControl(btn2);

nDockingToolbar1.Commands.Add(controlHost2);



Best Regards,
Nevron Support Team


Eric Sweet
Eric Sweet
Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)
Group: Forum Members
Posts: 14, Visits: 1
Thanks, I'll try it shortly. Just to make sure though, this will work with the built in command bars manager used by the diagramming control? Because the code looks nothing like the code from the sample application for adding a button.

Thanks again,
Eric
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

Hi Eric,

The example code above applies for NCommandBarsManager control, not for NDiagramCommandBarsManager.

In the example application (I guess you mean CommandBars example) to add another NCustomDiagramButtonCommand you need to set its ID property with value equal to the Id of the previous command + 1. Also in the example there is a filed customCommandIds of type ArrayList. In Reset method you should add a int value equal to the new command Id.

This way you should be able to add another button command to the diagram command bars manager.

Please, let us know if you still have problem with this.



Best Regards,
Nevron Support Team


Eric Sweet
Eric Sweet
Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)
Group: Forum Members
Posts: 14, Visits: 1
That did the trick. I changed the reset event to a for loop that increments the counter for each button added and it works. Thanks for the advice.

Eric
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search