Can't get Toolbars...

Stimulsoft Reports.NET discussion
Post Reply
Neo77
Posts: 16
Joined: Thu Apr 10, 2008 4:13 am
Location: Switzerland

Can't get Toolbars...

Post by Neo77 »

Hi

I'm using the following code to initialize a StiDesignerControl which is placed on a UserControl:

Code: Select all

StiService[] services = StiToolbarService.GetToolbarServices(stiDesigner);
				foreach (StiToolbarService tbservice in services)
				{
					if (tbservice.ToolBar != null)
					{
						tbservice.ToolBar.Visible = true;
						tbservice.ServiceEnabled = true;
					}
				}

				StiOptions.Designer.CodeTabVisible = false;
				StiOptions.Designer.ShowDesignerControlMainMenu = false;

				StiDesignerControl.DontSaveDesignerConfig = true;
				StiDesignerControl.DontSaveDockingPanelsConfig = true;
				StiDesignerControl.DontSaveEditorConfig = true;
				StiDesignerControl.DontAskSaveReport = true;
				StiDesignerControl.CanDesignerChangeReportFileName = false;

				StiDesignerControl.SavingReport += new StiSavingObjectEventHandler(StiDesigner_SavingReport);

				StiStandardToolbarService service = StiStandardToolbarService.GetService(stiDesigner);
				service.ShowReportNew = false;
				service.ShowReportOpen = false;
				service.ShowClose = false;

				stiDesigner.RefreshToolbars();
				stiDesigner.InvokeOrderToolbars();				

				_IsDesignerInitialized = true;
			}

None of the toolbars will show (even they are set to visible=true if I ste through the code).
The only way to display the toolbars in my application is to start the Designer and add the toolbars manually.

I'm using Version 2008.1.200 from 10 March 2008.

Many thanks for your help!
Chris
Neo77
Posts: 16
Joined: Thu Apr 10, 2008 4:13 am
Location: Switzerland

Can't get Toolbars...

Post by Neo77 »

Anyone please...?
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

Can't get Toolbars...

Post by Vital »

Hello Chris,

Please use following code if your designer already loaded:

Code: Select all

StiService[] services = StiToolbarService.GetToolbarServices(stiDesigner);
				foreach (StiToolbarService tbservice in services)
				{
					if (tbservice.ToolBar != null)
					{
						tbservice.ToolBar.Visible = true;
						tbservice.ToolBar.PlaceOnControl();

					}
				}
StiDesignerConfigService designerConfig = Services.GetService(typeof(StiDesignerConfigService)) as StiDesignerConfigService;
designerConfig.Save();
[/quote]
Neo77
Posts: 16
Joined: Thu Apr 10, 2008 4:13 am
Location: Switzerland

Can't get Toolbars...

Post by Neo77 »

Hi,

Thanks for your reply. I get an NullReferenceException on the line:

Code: Select all

tbservice.ToolBar.PlaceOnControl();
This is my complete code (also tried to place your code before assigning my report to the designer):

Code: Select all

StiReport stiReport = new StiReport();
				stiReport.Load(_Report.ReportObject.BinaryData);

				DataSet set = AgendaItemManager.GetAllAgendaItemsDataTable(ViaContext, _Report.Ou, null, null);
				
				stiReport.RegData(set);
				stiDesigner.Report = stiReport;

				StiService[] services = StiToolbarService.GetToolbarServices(stiDesigner);
				foreach (StiToolbarService tbservice in services)
				{
					if (tbservice.ToolBar != null)
					{
						tbservice.ToolBar.Visible = true;
						tbservice.ToolBar.PlaceOnControl();

					}
				}
				StiDesignerConfigService designerConfig = Stimulsoft.Report.StiConfig.Services.GetService(typeof(StiDesignerConfigService)) as StiDesignerConfigService;
				designerConfig.Save();
Stacktrace:
bei Stimulsoft.Controls.StiToolBar.PlaceOnControl()
bei srgits.Via.Desktop.AdminModule.Controls.ReportUserControl.UpdateView() in D:\win\VIA\Source\DesktopApp\Modules\Via.Desktop.AdminModule\Controls\ReportUserControl.cs:Zeile 142.
bei srgits.Via.Desktop.AdminModule.Controls.ReportUserControl.SetContext(Report report) in D:\win\VIA\Source\DesktopApp\Modules\Via.Desktop.AdminModule\Controls\ReportUserControl.cs:Zeile 67.
bei srgits.Via.Desktop.AdminModule.ModuleWorkItem.ExplorerView_AfterSelect(Object sender, TreeViewEventArgs e) in D:\win\VIA\Source\DesktopApp\Modules\Via.Desktop.AdminModule\ModuleWorkItem.cs:Zeile 212.
bei srgits.Via.Desktop.AdminModule.Views.ExplorerSmartPart.tvwTools_AfterSelect(Object sender, TreeViewEventArgs e) in D:\win\VIA\Source\DesktopApp\Modules\Via.Desktop.AdminModule\Views\ExplorerSmartPart.cs:Zeile 397.
bei System.Windows.Forms.TreeView.OnAfterSelect(TreeViewEventArgs e)
bei System.Windows.Forms.TreeView.TvnSelected(NMTREEVIEW* nmtv)
bei System.Windows.Forms.TreeView.WmNotify(Message& m)
bei System.Windows.Forms.TreeView.WndProc(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
bei System.Windows.Forms.Control.SendMessage(Int32 msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Forms.Control.ReflectMessageInternal(IntPtr hWnd, Message& m)
bei System.Windows.Forms.Control.WmNotify(Message& m)
bei System.Windows.Forms.Control.WndProc(Message& m)
bei System.Windows.Forms.ScrollableControl.WndProc(Message& m)
bei System.Windows.Forms.ContainerControl.WndProc(Message& m)
bei System.Windows.Forms.UserControl.WndProc(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
bei System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
bei System.Windows.Forms.Control.DefWndProc(Message& m)
bei System.Windows.Forms.TreeView.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
bei System.Windows.Forms.TreeView.WndProc(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
bei System.Windows.Forms.Application.Run(Form mainForm)
bei Microsoft.Practices.CompositeUI.WinForms.FormShellApplication`2.Start() in D:\win\VIA\Source\Library\CompositeUI.WinForms\FormShellApplication.cs:Zeile 31.
bei Microsoft.Practices.CompositeUI.CabApplication`1.Run() in D:\win\VIA\Source\Library\CompositeUI\CabApplication.cs:Zeile 81.
bei Via.DesktopShell.Program.Main() in D:\win\VIA\Source\DesktopApp\Via.DesktopShell\Program.cs:Zeile 143.
bei System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
bei System.Threading.ThreadHelper.ThreadStart()
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Can't get Toolbars...

Post by Edward »

The issue is confirmed.

We'll inform you when the solution is ready.

Thank you.
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

Can't get Toolbars...

Post by Vital »

Hello,

Please use following code:

Code: Select all

tbservice.ToolBar.Visible = true;
if (tbservice.ToolBar.Parent == null)
         stiDesignerControl1.pnToolbox.Controls.Add(tbservice.ToolBar);
tbservice.ToolBar.PlaceOnControl();
Thank you.
Neo77
Posts: 16
Joined: Thu Apr 10, 2008 4:13 am
Location: Switzerland

Can't get Toolbars...

Post by Neo77 »

Hi,

I'm using the following code (an version SR_2008.06.03_R2005) but still got now luck (and no toolbars)...

Code: Select all

StiReport.ClearImageCache();
				StiReport.ClearReportCache();

				StiStandardToolbarService service = StiStandardToolbarService.GetService(stiDesigner);
				service.ShowReportNew = false;
				service.ShowReportOpen = false;
				service.ShowClose = false;
				service.ToolBar.Visible = true;

				if (service.ToolBar.Parent == null)
				{
					stiDesigner.pnToolbox.Controls.Add(service.ToolBar);
				}

				service.ToolBar.PlaceOnControl();

				StiOptions.Designer.CodeTabVisible = false;

				StiDesignerControl.DontSaveDesignerConfig = true;
				StiDesignerControl.DontSaveDockingPanelsConfig = true;
				StiDesignerControl.DontSaveEditorConfig = true;
				StiDesignerControl.DontAskSaveReport = true;
				StiDesignerControl.CanDesignerChangeReportFileName = false;

				StiDesignerControl.SavingReport += new StiSavingObjectEventHandler(StiDesigner_SavingReport);

				stiDesigner.RefreshToolbars();
				stiDesigner.InvokeOrderToolbars();				

				_IsDesignerInitialized = true;

Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

Can't get Toolbars...

Post by Vital »

Hello,

Sorry your code is correct. Can you send small example with this problem?

Thank you.
Post Reply