Hiding toolbox items - current best way in code?

Stimulsoft Reports.NET discussion
Post Reply
Mark Smith
Posts: 37
Joined: Tue Jun 13, 2006 8:59 am
Location: Yorkshire, UK

Hiding toolbox items - current best way in code?

Post by Mark Smith »

6th July Build.

I need to be able to remove some of the toolbox items, until such time as I'm able to support their use. Specifically, I need to hide the chart and cross-tab comonent families.

I've tried creating an export from the config utility, but this seems to be ignored - here's the code I'm using to load it.

Code: Select all

private void SetDesignerConfiguration() {
  StiConfig.Load(DesignerConfig);
}

internal System.IO.Stream DesignerConfig {
  get {return GetResourceStream("Toucan.Reporter.Report.config");}
}

internal System.IO.Stream GetResourceStream(string AResourceName) {
  System.Reflection.Assembly assem = this.GetType().Assembly;
  System.IO.Stream result = assem.GetManifestResourceStream(AResourceName);
  return result;
}

I'm calling SetDesignerConfiguration from the initial entry point in my application, prior to loading my mainform, prior to creating a report, prior to loading a report, but the items I turned off still appear. I'm sure the resource is correct - I add a textReader into my GetResourceStream method to check that I could see the xml.

If I cannot do it via a config file, can I do it in code? I tried

Code: Select all

 StiChart ch = new StiChart();
ch.PlaceOnToolbox = false;
ch.ServiceEnabled = false;
With no success.
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

Hiding toolbox items - current best way in code?

Post by Jan »

Hello Mark,

You can use following code:

Code: Select all

StiServiceContainer services = StiConfig.Services.GetServices(typeof(StiComponent));
            foreach (StiComponent service in services)
            {
                if (service is Stimulsoft.Report.Chart.StiChart)
                {
                    service.PlaceOnToolbox = false;
                    service.ServiceEnabled = false;
                    break;
                }
            }
Thank you.
Mark Smith
Posts: 37
Joined: Tue Jun 13, 2006 8:59 am
Location: Yorkshire, UK

Hiding toolbox items - current best way in code?

Post by Mark Smith »

Hi Jan -

That works. Thank you!
Post Reply