May I ask a simple question about default chart commard toolbar position?


May I ask a simple question about default chart commard toolbar...
Author
Message
chunxia yang
chunxia yang
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)
Group: Forum Members
Posts: 2, Visits: 1
I have a simple but confused me whole afternoon question:

I create a chart, and use NChartCommandBarsManager as default command tools, I want the toolbar to default dock to left instead of top, but I didn't find the right property, I know this maybe a very easy question, but I didn't find the answer even searching in the document and on the web.

I have to use

for (int i = 0; i < nChartCommandBarsManager1.Toolbars.Count; i++)

{

nChartCommandBarsManager1.Toolbars[i].Dock = DockStyle.Left;

}

This kind of working except that if the control is not tall enough, other toolbar still dock on the top.

Another similiar question is how to customize command before application runs, like only remain tools toolbar?

My way is not good at all: I use a loop, and try to get the toolbar's name:

if (desc!= ChartCommandRange.Tools.ToString())

{

toolbar.Hide();

}

I am just start to try to use nevron, any comments are hightly appreicated.

 


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

Hello Chunxia Yang,

When you set the dock style to NDockingToolbar it may also change its index in toolbars collection.

One solution is to traverse toolbars backwards:

int nCount = nChartCommandBarsManager1.Toolbars.Count;
for (int i = nCount - 1; i >= 0; i--)
{
    nChartCommandBarsManager1.Toolbars[i].Dock =
DockStyle.Left;
}

To hide all but Tools toolbar you need to do the following:

for (int i = 0; i < nChartCommandBarsManager1.Toolbars.Count; i++)
{
    if (nChartCommandBarsManager1.Toolbars[i].Text != ChartCommandRange.Tools.ToString())
    {
        nChartCommandBarsManager1.Toolbars[i].Hide();
    }
}



Best Regards,
Nevron Support Team


chunxia yang
chunxia yang
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)
Group: Forum Members
Posts: 2, Visits: 1

Thanks for your answer

It works!!

I have one more question on this topic, what if I want to just remain some command in one group, for example, in Projection toolbar, I want to only remain zoom in/out command, currently I do the following:

if (desc == ChartCommandRange.Projection.ToString())

{

    foreach (var command in toolbar.Commands)

    {

        NCommand cmd = command as NCommand;

        string comText = cmd.ToString();

        if (comText != "Zoom In" && comText != "Zoom Out")

        {

           cmd.Properties.Visible = false;

        }

    }

}

 

I wandering if there are some better way to let me recoganize command except using the string. I find there is a enum ChartCommand, how use this enum?


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 chunxia yang,

You can also clear all commands in Projection toolbar and using NCommandBarsManager.Commander you can recreate only the commands you need:

NDockingToolbar projectionToolBar = nChartCommandBarsManager1.Toolbars[(int)ChartCommandRange.Projection];

NCommandContext zoomInContext = (NCommandContext)nChartCommandBarsManager1.Commander.Commands.GetCommandFromId((int)ChartCommand.ZoomIn).CreateUICommand();
NCommandContext zoomOutContext = (NCommandContext)nChartCommandBarsManager1.Commander.Commands.GetCommandFromId((int)ChartCommand.ZoomOut).CreateUICommand();

NCommand zoomIn = NCommand.FromContext(zoomInContext);
NCommand zoomOut = NCommand.FromContext(zoomOutContext);

projectionToolBar.Commands.Clear();

projectionToolBar.Commands.Add(zoomIn);
projectionToolBar.Commands.Add(zoomOut);



Best Regards,
Nevron Support Team


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