Managing the Properties of the TToolbox Panel
Posted by - NA - on 27 November 2008 05:36 PM
|
|
Overriding Toolbox actionsOne of the tasks most often performed while working with OLAP Toolbox is overriding standard actions upon pressing buttons. To do that, you need to handle the TOLAPGrid.ClickToolboxButton event. By examining the e.ItemType property in this event's handler, you can find out what button the user has pressed. For example, if there's a need to save the Grid state to the data base upon pressing the "Save" button in the toolbox (instead of the standard saving into a file), it can be done with the following code: RadarSoft.WinForms.Grid.TOLAPGrid grid; grid.ClickToolboxButton += new RadarSoft.WinForms.ClickToolboxButtonsEventHandler(ClickToolboxButton_handler); void ClickToolboxButton_handler(object sender, RadarSoft.WinForms.ClickToolboxButtonEventArgs e) { if (e.ItemType == RadarSoft.WinForms.ToolboxButtons.SaveAll) { SaveToDatabase(Grid.Serializer.XMLString); e.Handled = true; } } Adding Custom ButtonsThe TOLAPControlGeneral.Toolbox property provides an access to the panel of tools buttons of the Grid. ToolStripButton sampleButton = new ToolStripButton(); sampleButton.Text = "Sample button"; sampleButton.Click += new EventHandler(Sample_EventHandler); GridTable.Toolbox.Items.Add(sampleButton); ![]() Toolbox with the added button Managing the Buttons’ PropertiesTo manage the buttons’ property, you need to specify the TOLAPControlGeneral.ShowToolboxButton event handler, make sure that its e.ItemType argument’s field contains the button’s code (type), and change the appropriate property, available through e.Item. This event handler is executed when it is assigned (the first call) and upon changing the Grid state. Example: GridTable.ShowToolboxButton += new ShowToolboxButtonEventHandler(GridChart_ShowToolboxButton); void GridChart_ShowToolboxButton(object sender, ShowToolboxButtonEventArgs e) { switch (e.ItemType) { case ToolboxButtons.PrintPreview: case ToolboxButtons.ZoomGroup: e.Item.Visible = true; e.Item.Enabled = false; break; case ToolboxButtons.ApplyPalette: case ToolboxButtons.ApplySkin: case ToolboxButtons.PanelsGroup: e.Item.Visible = false; break; } } ![]() Standard view of the toolbox. ![]() The view of the toolbox after using the event handler. To refresh the buttons’ properties, you need to call the TOLAPControlGeneral.RefreshToolboxItems() manually. This will cause the execution of the TOLAPControlGeneral.ShowToolboxButton event handler for all the Grid’s buttons. Calling the Toolbox CommandsThe toolbox commands are called through the TOLAPControlGeneral.ToolboxCallCommand(ToolboxButtons AButtons) method with the button’s code (type) passed as a parameter. If the call is successful, the method returns true. Example: calling the print preview command GridTable.ToolboxCallCommand(ToolboxButtons.PrintPreview); Placing the Toolbox Outside the GridYou can use the toolbox separately from the Grid; that is place on the form an external toolbox as a separate component and set the TToolbox.Grid property (without this property toolbox buttons will be unavailable). ![]() The view of an external toolbox, not connected to the Grid. ![]() The view of an external toolbox, connected to the Grid. | |
|