'宣言 Public Class TaskPaneToolResizeEventArgs Inherits ToolEventArgs
public class TaskPaneToolResizeEventArgs : ToolEventArgs
Imports Infragistics.Shared Imports Infragistics.Win Imports Infragistics.Win.UltraWinToolbars Private Sub UltraButton4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UltraButton4.Click ' create a new task pane toolbar and add it to ' the toolbars collection of the manager Dim taskPane As New UltraTaskPaneToolbar("TaskPaneDemo2") taskPane.Text = "UltraExplorerBar" Me.UltraToolbarsManager1.Toolbars.Add(taskPane) ' create new task pane tools that will represents items ' in the task pane toolbar menu Dim explorerTool As New TaskPaneTool("explorer") ' initialize their captions explorerTool.SharedProps.Caption = "ExplorerBar" ' associate a control that will be displayed when the tool ' is selected explorerTool.Control = Me.ultraExplorerBar1 ' create the root level tools Me.UltraToolbarsManager1.Tools.Add(explorerTool) ' add the tools to the task pane toolbar taskPane.Tools.AddTool("explorer") ' dock the toolbar to the left taskPane.DockedPosition = DockedPosition.Left ' by default have the controls resize to fill the available ' content area of the task pane taskPane.ToolResizeMode = TaskPaneToolResizeMode.AutoSizeBothDimensions ' however, for the explorerbar, we want to just ' initialize the non scrolling extent - i.e. ' when scrolling vertically, the width of the ' control will be adjusted but not the height explorerTool.ResizeMode = TaskPaneToolResizeMode.AutoSizeNonScrollingDimension ' when the task pane toolbar does not have enough room ' to display the full height of the control, scroll ' buttons are displayed. the appearance can be controlled ' with properties on the UltraTaskPaneToolbar taskPane.ScrollButtonAppearance.ForeColor = Color.Black End Sub Private Sub UltraToolbarsManager1_TaskPaneToolResize(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinToolbars.TaskPaneToolResizeEventArgs) Handles UltraToolbarsManager1.TaskPaneToolResize ' The TaskPaneToolResize event is invoked whenever the ' size of the control associated with the SelectedTaskPaneTool ' is to be adjusted. This occurs when the tool is selected ' as well as when the task pane toolbar is resized. ' take the recommended size as the default size If TypeOf e.Control Is Infragistics.Win.UltraWinExplorerBar.UltraExplorerBar Then Dim newSize As Size = e.NewControlSize ' initialize the width so we can ask the explorer bar ' for the height. note, this will only work properly ' if the scrollbars property of the control is set ' to never e.Control.Width = newSize.Width ' use the larger of the available height and ' the height needed by the explorer bar to show ' its contents newSize.Height = Math.Max(e.ContentAreaSize.Height, CType(e.Control, Infragistics.Win.UltraWinExplorerBar.UltraExplorerBar).GetLogicalControlHeight()) e.NewControlSize = newSize End If End Sub
using Infragistics.Shared; using Infragistics.Win; using Infragistics.Win.UltraWinToolbars; private void ultraButton4_Click(object sender, System.EventArgs e) { // create a new task pane toolbar and add it to // the toolbars collection of the manager UltraTaskPaneToolbar taskPane = new UltraTaskPaneToolbar("TaskPaneDemo2"); taskPane.Text = "UltraExplorerBar"; this.ultraToolbarsManager1.Toolbars.Add(taskPane); // create new task pane tools that will represents items // in the task pane toolbar menu TaskPaneTool explorerTool = new TaskPaneTool("explorer"); // initialize their captions explorerTool.SharedProps.Caption = "ExplorerBar"; // associate a control that will be displayed when the tool // is selected explorerTool.Control = this.ultraExplorerBar1; // create the root level tools this.ultraToolbarsManager1.Tools.Add( explorerTool ); // add the tools to the task pane toolbar taskPane.Tools.AddTool("explorer"); // dock the toolbar to the left taskPane.DockedPosition = DockedPosition.Left; // by default have the controls resize to fill the available // content area of the task pane taskPane.ToolResizeMode = TaskPaneToolResizeMode.AutoSizeBothDimensions; // however, for the explorerbar, we want to just // initialize the non scrolling extent - i.e. // when scrolling vertically, the width of the // control will be adjusted but not the height explorerTool.ResizeMode = TaskPaneToolResizeMode.AutoSizeNonScrollingDimension; // when the task pane toolbar does not have enough room // to display the full height of the control, scroll // buttons are displayed. the appearance can be controlled // with properties on the UltraTaskPaneToolbar taskPane.ScrollButtonAppearance.ForeColor = Color.Black; } private void ultraToolbarsManager1_TaskPaneToolResize(object sender, Infragistics.Win.UltraWinToolbars.TaskPaneToolResizeEventArgs e) { // The TaskPaneToolResize event is invoked whenever the // size of the control associated with the SelectedTaskPaneTool // is to be adjusted. This occurs when the tool is selected // as well as when the task pane toolbar is resized. // take the recommended size as the default size if (e.Control is Infragistics.Win.UltraWinExplorerBar.UltraExplorerBar) { Size newSize = e.NewControlSize; // initialize the width so we can ask the explorer bar // for the height. note, this will only work properly // if the scrollbars property of the control is set // to never e.Control.Width = newSize.Width; // use the larger of the available height and // the height needed by the explorer bar to show // its contents newSize.Height = Math.Max(e.ContentAreaSize.Height, ((Infragistics.Win.UltraWinExplorerBar.UltraExplorerBar)e.Control).GetLogicalControlHeight()); e.NewControlSize = newSize; } }