GrapeCity.Win.Common 名前空間 : PlusPakPickerBase クラス |
Public MustInherit Class PlusPakPickerBase Inherits PlusPakControlBase
public abstract class PlusPakPickerBase : PlusPakControlBase
次のサンプルコードは、派生クラスのGrapeCity.Win.Containers.GcComboFrameを使用して、PlusPakPickerBaseクラスのメソッド、プロパティ、およびコレクションの使用方法を示します。これはプロジェクトにコピー&ペーストするだけですぐに実行できる完成したサンプルです。この例では、System.Windows.Forms.TextBoxコントロール(textBox1)をgcComboFrame1のGrapeCity.Win.Containers.GcComboFrame.ContentPanelに内容コントロールとして追加し、System.Windows.Forms.ListBoxコントロール(listBox1)をgcComboFrame1のGrapeCity.Win.Containers.GcComboFrame.DropDownControlにドロップダウンコントロールとして追加します。comboBox1から項目を選択することで、GrapeCity.Win.Containers.GcComboFrameに表示するサイドボタンの種類を決定できます。ただし、DropDownButtonは、ユーザーにドロップダウンウィンドウを開閉する手段を提供するため、常に表示されます。
using System; using System.ComponentModel; using System.Drawing; using System.Windows.Forms; using GrapeCity.Win.Common; namespace GrapeCity.Win.PlusPak.SampleCodes_CS { public class GcComboFrameForm : Form { private TextBox textBox1; private ListBox listBox1; private ComboBox comboBox1; private Label label1; private GrapeCity.Win.Containers.GcComboFrame gcComboFrame1; private void InitializeComponent() { this.textBox1 = new System.Windows.Forms.TextBox(); this.listBox1 = new System.Windows.Forms.ListBox(); this.comboBox1 = new System.Windows.Forms.ComboBox(); this.label1 = new System.Windows.Forms.Label(); this.gcComboFrame1 = new GrapeCity.Win.Containers.GcComboFrame(); ((System.ComponentModel.ISupportInitialize)(this.gcComboFrame1)).BeginInit(); this.gcComboFrame1.SuspendLayout(); this.SuspendLayout(); // // textBox1 // this.textBox1.Size = new System.Drawing.Size(160, 23); this.textBox1.TabIndex = 0; // // listBox1 // this.listBox1.Location = new System.Drawing.Point(0, 0); this.listBox1.Name = "listBox1"; this.listBox1.Size = new System.Drawing.Size(120, 113); this.listBox1.TabIndex = 1; // // comboBox1 // this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBox1.FormattingEnabled = true; this.comboBox1.Location = new System.Drawing.Point(21, 28); this.comboBox1.Name = "comboBox1"; this.comboBox1.Size = new System.Drawing.Size(107, 21); this.comboBox1.TabIndex = 1; // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(22, 9); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(65, 13); this.label1.TabIndex = 2; this.label1.Text = "Side Button:"; // // gcComboFrame1 // this.gcComboFrame1.Location = new System.Drawing.Point(154, 28); this.gcComboFrame1.Name = "gcComboFrame1"; this.gcComboFrame1.Size = new System.Drawing.Size(177, 22); this.gcComboFrame1.TabIndex = 0; // // GcComboFrameForm // this.ClientSize = new System.Drawing.Size(387, 70); this.Controls.Add(this.label1); this.Controls.Add(this.comboBox1); this.Controls.Add(this.gcComboFrame1); this.Name = "GcComboFrameForm"; ((System.ComponentModel.ISupportInitialize)(this.gcComboFrame1)).EndInit(); this.gcComboFrame1.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); } public GcComboFrameForm() { InitializeComponent(); // Initialize gcComboFram1. InitialzeMyGcComboFrame(); Type[] sideButtonTypes = new Type[] { typeof(DropDownButton), typeof(SideButton), typeof(SpinButton), typeof(SymbolButton), typeof(ColorPickerButton), }; // Change gcComboFrame1's side button's visible when comboBox1's selected index is changed. this.comboBox1.SelectedIndexChanged += new EventHandler(ComboBox1_SelectedIndexChanged); // Set up comboBox1 data bind to different types of side buttons. this.comboBox1.DisplayMember = "Name"; this.comboBox1.DataSource = sideButtonTypes; } // Initialize gcComboFrame1. private void InitialzeMyGcComboFrame() { SetComboFrameContentControl(); SetComboFrameDropDownControl(); CreateAndAddComboFrameSideButtons(); // Set gcComboFrame1's border style and color. this.gcComboFrame1.BorderStyle = BorderStyle.FixedSingle; this.gcComboFrame1.SingleBorderColor = Color.Black; InitializeComboFrameDropDowSettings(); // Add event hanlder for the ShortcutKeyDown event. this.gcComboFrame1.ShortcutKeyDown += new EventHandler<KeyEventArgs>(GcComboFrame1_ShortcutKeyDown); // Add some events for gcComboFrame1. this.gcComboFrame1.DropDownOpening += new EventHandler<CancelEventArgs>(GcComboFrame1_DropDownOpening); this.gcComboFrame1.DropDownOpened += new EventHandler(GcComboFrame1_DropDownOpened); this.gcComboFrame1.DropDownClosing += new EventHandler<DropDownClosingEventArgs>(GcComboFrame1_DropDownClosing); this.gcComboFrame1.DropDownClosed += new EventHandler<DropDownClosedEventArgs>(GcComboFrame1_DropDownClosed); this.gcComboFrame1.DropDownSizeChanged += new EventHandler(GcComboFrame1_DropDownSizeChanged); } private void CreateAndAddComboFrameSideButtons() { // Create and add some side buttons for gcComboFrame1. SideButtonBase[] sideButtons = new SideButtonBase[] { CreateDropDownButton(), CreateSideButton(), CreateSpinButton(), CreateSymbolButton(), CreateColorPickerButton() }; this.gcComboFrame1.SideButtons.AddRange(sideButtons); } private void InitializeComboFrameDropDowSettings() { // Sets the AutoDropDown to true to open the gcComboFrame1's drop-down window automatically // after the control gets focus. this.gcComboFrame1.DropDownSettings.AutoDropDown = true; // Set drop-down windows's size . this.gcComboFrame1.DropDownSettings.Size = new Size(this.gcComboFrame1.Width, 100); // Set AllowResize to true to enable user UI resizes the drop-down window by sizing grip. this.gcComboFrame1.DropDownSettings.AllowResize = true; // Opens the drop-down window from the below-right of gcComboFrame1. this.gcComboFrame1.DropDownSettings.DropDownDirection = DropDownDirection.BelowRight; // Set the opening and closing animation for the drop-down window. this.gcComboFrame1.DropDownSettings.OpeningAnimation = DropDownAnimation.Fade; this.gcComboFrame1.DropDownSettings.ClosingAnimation = DropDownAnimation.Fade; // Hide the separator between the content of the drop-down window and the resizing grip. this.gcComboFrame1.DropDownSettings.ShowSeparator = false; // Sets the BorderStyle of the drop-down window. this.gcComboFrame1.DropDownSettings.BorderStyle = BorderStyle.FixedSingle; // Sets the color of the border of drop-down window. this.gcComboFrame1.DropDownSettings.SingleBorderColor = Color.Black; // Enables the shadow effect of the drop-down window. this.gcComboFrame1.DropDownSettings.ShowShadow = true; } private void SetComboFrameContentControl() { // Sets some properties of textBox1 to fit it into the ContentPanel of gcComboFrame1. this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.None; this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill; this.textBox1.Multiline = true; // Set textBox1 as gcComboFram1's content control. this.gcComboFrame1.ContentPanel.Controls.Add(this.textBox1); } private void SetComboFrameDropDownControl() { // Initialize the listBox1. this.listBox1.BorderStyle = BorderStyle.None; this.listBox1.Dock = DockStyle.Fill; this.listBox1.Items.AddRange(new string[] { "item1", "item2", "item3", "item4", "item5"}); // Set listBox1 as gcComboFrame1's drop-down control. this.gcComboFrame1.DropDownControl = this.listBox1; } private void GcComboFrame1_ShortcutKeyDown(object sender, KeyEventArgs e) { // Forbid the process of Escape for GcComboFrame // and after setting the Handled to true, pressing // Esc can not close the drop-down window. if (e.KeyCode == Keys.Escape) { e.Handled = true; } } private void GcComboFrame1_DropDownOpening(object sender, CancelEventArgs e) { // Set the drop-down window's size to a specific size before the drop-down window opens. this.gcComboFrame1.DropDownSettings.Size = new Size(this.gcComboFrame1.Width, 100); } private void GcComboFrame1_DropDownClosing(object sender, DropDownClosingEventArgs e) { // Set textBox1's Text property to the selected item of listBox1. if (this.listBox1.SelectedIndex != -1) { this.textBox1.Text = this.listBox1.SelectedItem.ToString(); } // Output the reason why the drop-down window is closing. this.Text = "CloseReason = " + e.CloseReason.ToString(); } private void GcComboFrame1_DropDownClosed(object sender, DropDownClosedEventArgs e) { // Change the SymbolButton's SymbolDirection after drop-down window has closed. (this.gcComboFrame1.SideButtons["SymbolButton"] as SymbolButton).SymbolDirection = SymbolDirection.Down; // Output the reason why the drop-down window is closed. this.Text = "CloseReason = " + e.CloseReason.ToString(); } private void GcComboFrame1_DropDownSizeChanged(object sender, EventArgs e) { // Output the size of drop-down window to the Text of gcComboFrame1's parent form. this.Text = "Drop-down window's size: " + this.gcComboFrame1.DropDownSettings.Size; } // Use this field to record the image of ColorPickerButton during picking color. private Image colorPickerImage = null; // Returns a ColorPickerButton instance for gcComboFrame1. private SideButtonBase CreateColorPickerButton() { ColorPickerButton colorPickerButton = new ColorPickerButton(); // Specify a unique name for this button. colorPickerButton.Name = "ColorPickerButton"; // Set this button not be shown. colorPickerButton.Visible = ButtonVisibility.NotShown; // Set button's position colorPickerButton.Position = ButtonPosition.RightOutside; // Set button's width. colorPickerButton.ButtonWidth = 25; // Add event handlers for the events of this button. colorPickerButton.BeginPickColor += new EventHandler(ColorPickerButton_BeginPickColor); colorPickerButton.PickingColor += new EventHandler<PickingColorEventArgs>(ColorPickerButton_PickingColor); colorPickerButton.EndPickColor += new EventHandler<EndPickColorEventArgs>(ColorPickerButton_EndPickColor); return colorPickerButton; } private void ColorPickerButton_BeginPickColor(object sender, EventArgs e) { // Clear the text of textBox1. this.textBox1.Clear(); // Record the original image and set the Image property to null. ColorPickerButton colorPickerButton = sender as ColorPickerButton; colorPickerImage = colorPickerButton.Image; colorPickerButton.Image = null; } private void ColorPickerButton_PickingColor(object sender, PickingColorEventArgs e) { // Set textBox1's Text property to the picking color. this.textBox1.Text = e.Color.ToString(); // Set ColorPickerButton's background color to the picking color. (sender as ColorPickerButton).BackColor = e.Color; } private void ColorPickerButton_EndPickColor(object sender, EndPickColorEventArgs e) { // Add the color into listBox1 if the picking of color is succussful. if (PickColorResult.OK == e.Result) { DialogResult result = MessageBox.Show("Do you want to add the color into list box ?", "Picking color successful", MessageBoxButtons.YesNo); if (DialogResult.Yes == result) { this.listBox1.Items.Add(e.Color.ToString()); } } // Clear the text. this.textBox1.Clear(); // Restore the displaying image of ColorPickerButton. ColorPickerButton colorPickerButton = sender as ColorPickerButton; colorPickerButton.Image = colorPickerImage; // Restore the background color of ColorPickerButton. colorPickerButton.BackColor = Color.Empty; colorPickerButton.UseVisualStyleBackColor = true; } // Returns a DropDownButton instance for gcComboFrame1. private SideButtonBase CreateDropDownButton() { DropDownButton dropDownButton = new DropDownButton(); // Specify a unique name for this button. dropDownButton.Name = "DropDownButton"; // Set the width of this button. dropDownButton.ButtonWidth = 20; // Show this button always. dropDownButton.Visible = ButtonVisibility.ShowAlways; return dropDownButton; } // Returns a SideButton instance for gcComboFrame1. private SideButtonBase CreateSideButton() { SideButton sideButton = new SideButton(); // Specify a unique name for this button. sideButton.Name = "SideButton"; // Set button text. sideButton.Text = "Add a item"; // Set button's width. sideButton.ButtonWidth = 70; // Set this side button not to show in GcComboFrame. sideButton.Visible = ButtonVisibility.NotShown; // Set this side button to position at outside of GcComboFrame's right border. sideButton.Position = ButtonPosition.RightOutside; // Set the fat appearance for this button, and these settings will take effect when // its associated GcComboFrame's FlatStyle is Flat. sideButton.FlatAppearance.BorderColor = Color.Red; sideButton.FlatAppearance.BorderSize = 2; sideButton.FlatAppearance.CheckedBackColor = Color.Blue; sideButton.FlatAppearance.MouseDownBackColor = Color.Yellow; sideButton.FlatAppearance.MouseOverBackColor = Color.Green; sideButton.Click += new EventHandler(SideButton_Click); return sideButton; } // Add a item into listBox1 when SideButton is clicked. private void SideButton_Click(object sender, EventArgs e) { if (this.textBox1.Text != string.Empty) { this.listBox1.Items.Add(this.textBox1.Text); this.textBox1.Clear(); } else { MessageBox.Show("You must input a string first !"); } } // Returns a SymbolButton instance for gcComboFrame1. private SideButtonBase CreateSymbolButton() { SymbolButton symbolButton = new SymbolButton(); // Specify a unique name for this button. symbolButton.Name = "SymbolButton"; // Specify one kind of symbol and the symbol's direction for this button. symbolButton.Symbol = Symbols.DoubleArrow; symbolButton.SymbolDirection = SymbolDirection.Down; // Set this button not be shown. symbolButton.Visible = ButtonVisibility.NotShown; // Set button's position. symbolButton.Position = ButtonPosition.RightOutside; return symbolButton; } // Show or hide side buttons for gcComboFrame1 when comboBox1's selected index is changed. private void ComboBox1_SelectedIndexChanged(object sender, EventArgs e) { foreach (SideButtonBase sideButton in this.gcComboFrame1.SideButtons) { if (sideButton.Name == this.comboBox1.Text) { // Shows the side button selected from comboBox1. sideButton.Visible = ButtonVisibility.ShowAlways; } else { // Hides the side button that are not selected from comboBox1. sideButton.Visible = ButtonVisibility.NotShown; } } // Always show the DropDownButton. this.gcComboFrame1.SideButtons["DropDownButton"].Visible = ButtonVisibility.ShowAlways; } private void Button1_Click(object sender, EventArgs e) { this.gcComboFrame1.DroppedDown = true; } private void GcComboFrame1_DropDownOpened(object sender, EventArgs e) { // Change the SymbolButton's SymbolDirection after drop-down window has opened. (this.gcComboFrame1.SideButtons["SymbolButton"] as SymbolButton).SymbolDirection = SymbolDirection.Up; } // Returns a SpinButton instance for gcComboFrame1. private SideButtonBase CreateSpinButton() { SpinButton spinButton = new SpinButton(); // Specify a unique name for this button. spinButton.Name = "SpinButton"; // Set the Interval for spinButton. spinButton.Interval = 100; spinButton.SpinUp += new EventHandler(SpinButton_SpinUp); spinButton.SpinDown += new EventHandler(SpinButton_SpinDown); // Not show spinButton in gcComboFrame1. spinButton.Visible = ButtonVisibility.NotShown; return spinButton; } // Increase the seleced index of listBox1 when spin is down. private void SpinButton_SpinDown(object sender, EventArgs e) { if (this.listBox1.SelectedIndex < this.listBox1.Items.Count - 1) { this.listBox1.SelectedIndex += 1; } else { this.listBox1.SelectedIndex = this.listBox1.Items.Count - 1; } this.textBox1.Text = this.listBox1.SelectedItem.ToString(); } // Decrease the seleced index of listBox1 when spin is down. private void SpinButton_SpinUp(object sender, EventArgs e) { if (this.listBox1.SelectedIndex > 0) { this.listBox1.SelectedIndex -= 1; } else { this.listBox1.SelectedIndex = 0; } this.textBox1.Text = this.listBox1.SelectedItem.ToString(); } [STAThread] public static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new GcComboFrameForm()); } } }
Imports System Imports System.ComponentModel Imports System.Drawing Imports System.Windows.Forms Imports GrapeCity.Win.Common Imports GrapeCity.Win.Containers Namespace GrapeCity.Win.PlusPak.SampleCodes_VB Public Class GcComboFrameForm Inherits Form Private textBox1 As TextBox Private listBox1 As ListBox Private comboBox1 As ComboBox Private label1 As Label Private gcComboFrame1 As GcComboFrame Private Sub InitializeComponent() Me.textBox1 = New System.Windows.Forms.TextBox() Me.listBox1 = New System.Windows.Forms.ListBox() Me.comboBox1 = New System.Windows.Forms.ComboBox() Me.label1 = New System.Windows.Forms.Label() Me.gcComboFrame1 = New GcComboFrame() DirectCast((Me.gcComboFrame1), System.ComponentModel.ISupportInitialize).BeginInit() Me.gcComboFrame1.SuspendLayout() Me.SuspendLayout() ' ' textBox1 ' Me.textBox1.Size = New System.Drawing.Size(160, 23) Me.textBox1.TabIndex = 0 ' ' listBox1 ' Me.listBox1.Location = New System.Drawing.Point(0, 0) Me.listBox1.Name = "listBox1" Me.listBox1.Size = New System.Drawing.Size(120, 113) Me.listBox1.TabIndex = 1 ' ' comboBox1 ' Me.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList Me.comboBox1.FormattingEnabled = True Me.comboBox1.Location = New System.Drawing.Point(21, 28) Me.comboBox1.Name = "comboBox1" Me.comboBox1.Size = New System.Drawing.Size(107, 21) Me.comboBox1.TabIndex = 1 ' ' label1 ' Me.label1.AutoSize = True Me.label1.Location = New System.Drawing.Point(22, 9) Me.label1.Name = "label1" Me.label1.Size = New System.Drawing.Size(65, 13) Me.label1.TabIndex = 2 Me.label1.Text = "Side Button:" ' ' gcComboFrame1 ' Me.gcComboFrame1.Location = New System.Drawing.Point(154, 28) Me.gcComboFrame1.Name = "gcComboFrame1" Me.gcComboFrame1.Size = New System.Drawing.Size(177, 22) Me.gcComboFrame1.TabIndex = 0 ' ' GcComboFrameForm ' Me.ClientSize = New System.Drawing.Size(387, 70) Me.Controls.Add(Me.label1) Me.Controls.Add(Me.comboBox1) Me.Controls.Add(Me.gcComboFrame1) Me.Name = "GcComboFrameForm" DirectCast((Me.gcComboFrame1), System.ComponentModel.ISupportInitialize).EndInit() Me.gcComboFrame1.ResumeLayout(False) Me.ResumeLayout(False) Me.PerformLayout() End Sub Public Sub New() InitializeComponent() ' Initialize gcComboFram1. InitialzeMyGcComboFrame() Dim sideButtonTypes As Type() = New Type() _ { _ GetType(DropDownButton), _ GetType(SideButton), _ GetType(SpinButton), _ GetType(SymbolButton), _ GetType(ColorPickerButton) _ } ' Change gcComboFrame1's side button's visible when comboBox1's selected index is changed. AddHandler Me.comboBox1.SelectedIndexChanged, AddressOf ComboBox1_SelectedIndexChanged ' Set up comboBox1 data bind to different types of side buttons. Me.comboBox1.DisplayMember = "Name" Me.comboBox1.DataSource = sideButtonTypes End Sub ' Initialize gcComboFrame1. Private Sub InitialzeMyGcComboFrame() SetComboFrameContentControl() SetComboFrameDropDownControl() CreateAndAddComboFrameSideButtons() ' Set gcComboFrame1's border style and color. Me.gcComboFrame1.BorderStyle = BorderStyle.FixedSingle Me.gcComboFrame1.SingleBorderColor = Color.Black InitializeComboFrameDropDowSettings() ' Add event hanlder for the ShortcutKeyDown event. AddHandler Me.gcComboFrame1.ShortcutKeyDown, AddressOf GcComboFrame1_ShortcutKeyDown ' Add some events for gcComboFrame1. AddHandler Me.gcComboFrame1.DropDownOpening, AddressOf GcComboFrame1_DropDownOpening AddHandler Me.gcComboFrame1.DropDownOpened, AddressOf GcComboFrame1_DropDownOpened AddHandler Me.gcComboFrame1.DropDownClosing, AddressOf GcComboFrame1_DropDownClosing AddHandler Me.gcComboFrame1.DropDownClosed, AddressOf GcComboFrame1_DropDownClosed AddHandler Me.gcComboFrame1.DropDownSizeChanged, AddressOf GcComboFrame1_DropDownSizeChanged End Sub Private Sub CreateAndAddComboFrameSideButtons() ' Create and add some side buttons for gcComboFrame1. Dim sideButtons As SideButtonBase() = New SideButtonBase() {CreateDropDownButton(), CreateSideButton(), CreateSpinButton(), CreateSymbolButton(), CreateColorPickerButton()} Me.gcComboFrame1.SideButtons.AddRange(sideButtons) End Sub Private Sub InitializeComboFrameDropDowSettings() ' Sets the AutoDropDown to true to open the gcComboFrame1's drop-down window automatically ' after the control gets focus. Me.gcComboFrame1.DropDownSettings.AutoDropDown = True ' Set drop-down windows's size . Me.gcComboFrame1.DropDownSettings.Size = New Size(Me.gcComboFrame1.Width, 100) ' Set AllowResize to true to enable user UI resizes the drop-down window by sizing grip. Me.gcComboFrame1.DropDownSettings.AllowResize = True ' Opens the drop-down window from the below-right of gcComboFrame1. Me.gcComboFrame1.DropDownSettings.DropDownDirection = DropDownDirection.BelowRight ' Set the opening and closing animation for the drop-down window. Me.gcComboFrame1.DropDownSettings.OpeningAnimation = DropDownAnimation.Fade Me.gcComboFrame1.DropDownSettings.ClosingAnimation = DropDownAnimation.Fade ' Hide the separator between the content of the drop-down window and the resizing grip. Me.gcComboFrame1.DropDownSettings.ShowSeparator = False ' Sets the BorderStyle of the drop-down window. Me.gcComboFrame1.DropDownSettings.BorderStyle = BorderStyle.FixedSingle ' Sets the color of the border of drop-down window. Me.gcComboFrame1.DropDownSettings.SingleBorderColor = Color.Black ' Enables the shadow effect of the drop-down window. Me.gcComboFrame1.DropDownSettings.ShowShadow = True End Sub Private Sub SetComboFrameContentControl() ' Sets some properties of textBox1 to fit it into the ContentPanel of gcComboFrame1. Me.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.None Me.textBox1.Dock = System.Windows.Forms.DockStyle.Fill Me.textBox1.Multiline = True ' Set textBox1 as gcComboFram1's content control. Me.gcComboFrame1.ContentPanel.Controls.Add(Me.textBox1) End Sub Private Sub SetComboFrameDropDownControl() ' Initialize the listBox1. Me.listBox1.BorderStyle = BorderStyle.None Me.listBox1.Dock = DockStyle.Fill Me.listBox1.Items.AddRange(New String() {"item1", "item2", "item3", "item4", "item5"}) ' Set listBox1 as gcComboFrame1's drop-down control. Me.gcComboFrame1.DropDownControl = Me.listBox1 End Sub Private Sub GcComboFrame1_ShortcutKeyDown(ByVal sender As Object, ByVal e As KeyEventArgs) ' Forbid the process of Escape for GcComboFrame ' and after setting the Handled to true, pressing ' Esc can not close the drop-down window. If e.KeyCode = Keys.Escape Then e.Handled = True End If End Sub Private Sub GcComboFrame1_DropDownOpening(ByVal sender As Object, ByVal e As CancelEventArgs) ' Set the drop-down window's size to a specific size before the drop-down window opens. Me.gcComboFrame1.DropDownSettings.Size = New Size(Me.gcComboFrame1.Width, 100) End Sub Private Sub GcComboFrame1_DropDownClosing(ByVal sender As Object, ByVal e As DropDownClosingEventArgs) ' Set textBox1's Text property to the selected item of listBox1. If Me.listBox1.SelectedIndex <> -1 Then Me.textBox1.Text = Me.listBox1.SelectedItem.ToString() End If ' Output the reason why the drop-down window is closing. Me.Text = "CloseReason = " + e.CloseReason.ToString() End Sub Private Sub GcComboFrame1_DropDownClosed(ByVal sender As Object, ByVal e As DropDownClosedEventArgs) ' Change the SymbolButton's SymbolDirection after drop-down window has closed. TryCast(Me.gcComboFrame1.SideButtons("SymbolButton"), SymbolButton).SymbolDirection = SymbolDirection.Down ' Output the reason why the drop-down window is closed. Me.Text = "CloseReason = " + e.CloseReason.ToString() End Sub Private Sub GcComboFrame1_DropDownSizeChanged(ByVal sender As Object, ByVal e As EventArgs) ' Output the size of drop-down window to the Text of gcComboFrame1's parent form. Me.Text = "Drop-down window's size: " + Me.gcComboFrame1.DropDownSettings.Size.ToString() End Sub ' Use this field to record the image of ColorPickerButton during picking color. Private colorPickerImage As Image = Nothing ' Returns a ColorPickerButton instance for gcComboFrame1. Private Function CreateColorPickerButton() As SideButtonBase Dim colorPickerButton As New ColorPickerButton() ' Specify a unique name for this button. colorPickerButton.Name = "ColorPickerButton" ' Set this button not be shown. colorPickerButton.Visible = ButtonVisibility.NotShown ' Set button's position colorPickerButton.Position = ButtonPosition.RightOutside ' Set button's width. colorPickerButton.ButtonWidth = 25 ' Add event handlers for the events of this button. AddHandler colorPickerButton.BeginPickColor, AddressOf ColorPickerButton_BeginPickColor AddHandler colorPickerButton.PickingColor, AddressOf ColorPickerButton_PickingColor AddHandler colorPickerButton.EndPickColor, AddressOf ColorPickerButton_EndPickColor Return colorPickerButton End Function Private Sub ColorPickerButton_BeginPickColor(ByVal sender As Object, ByVal e As EventArgs) ' Clear the text of textBox1. Me.textBox1.Clear() ' Record the original image and set the Image property to null. Dim colorPickerButton As ColorPickerButton = TryCast(sender, ColorPickerButton) colorPickerImage = colorPickerButton.Image colorPickerButton.Image = Nothing End Sub Private Sub ColorPickerButton_PickingColor(ByVal sender As Object, ByVal e As PickingColorEventArgs) ' Set textBox1's Text property to the picking color. Me.textBox1.Text = e.Color.ToString() ' Set ColorPickerButton's background color to the picking color. TryCast(sender, ColorPickerButton).BackColor = e.Color End Sub Private Sub ColorPickerButton_EndPickColor(ByVal sender As Object, ByVal e As EndPickColorEventArgs) ' Add the color into listBox1 if the picking of color is succussful. If PickColorResult.OK = e.Result Then Dim result As DialogResult = MessageBox.Show("Do you want to add the color into list box ?", "Picking color successful", MessageBoxButtons.YesNo) If DialogResult.Yes = result Then Me.listBox1.Items.Add(e.Color.ToString()) End If End If ' Clear the text. Me.textBox1.Clear() ' Restore the displaying image of ColorPickerButton. Dim colorPickerButton As ColorPickerButton = TryCast(sender, ColorPickerButton) colorPickerButton.Image = colorPickerImage ' Restore the background color of ColorPickerButton. colorPickerButton.BackColor = Color.Empty colorPickerButton.UseVisualStyleBackColor = True End Sub ' Returns a DropDownButton instance for gcComboFrame1. Private Function CreateDropDownButton() As SideButtonBase Dim dropDownButton As New DropDownButton() ' Specify a unique name for this button. dropDownButton.Name = "DropDownButton" ' Set the width of this button. dropDownButton.ButtonWidth = 20 ' Show this button always. dropDownButton.Visible = ButtonVisibility.ShowAlways Return dropDownButton End Function ' Returns a SideButton instance for gcComboFrame1. Private Function CreateSideButton() As SideButtonBase Dim sideButton As New SideButton() ' Specify a unique name for this button. sideButton.Name = "SideButton" ' Set button text. sideButton.Text = "Add a item" ' Set button's width. sideButton.ButtonWidth = 70 ' Set this side button not to show in GcComboFrame. sideButton.Visible = ButtonVisibility.NotShown ' Set this side button to position at outside of GcComboFrame's right border. sideButton.Position = ButtonPosition.RightOutside ' Set the fat appearance for this button, and these settings will take effect when ' its associated GcComboFrame's FlatStyle is Flat. sideButton.FlatAppearance.BorderColor = Color.Red sideButton.FlatAppearance.BorderSize = 2 sideButton.FlatAppearance.CheckedBackColor = Color.Blue sideButton.FlatAppearance.MouseDownBackColor = Color.Yellow sideButton.FlatAppearance.MouseOverBackColor = Color.Green AddHandler sideButton.Click, AddressOf SideButton_Click Return sideButton End Function ' Add a item into listBox1 when SideButton is clicked. Private Sub SideButton_Click(ByVal sender As Object, ByVal e As EventArgs) If Me.textBox1.Text <> String.Empty Then Me.listBox1.Items.Add(Me.textBox1.Text) Me.textBox1.Clear() Else MessageBox.Show("You must input a string first !") End If End Sub ' Returns a SymbolButton instance for gcComboFrame1. Private Function CreateSymbolButton() As SideButtonBase Dim symbolButton As New SymbolButton() ' Specify a unique name for this button. symbolButton.Name = "SymbolButton" ' Specify one kind of symbol and the symbol's direction for this button. symbolButton.Symbol = Symbols.DoubleArrow symbolButton.SymbolDirection = SymbolDirection.Down ' Set this button not be shown. symbolButton.Visible = ButtonVisibility.NotShown ' Set button's position. symbolButton.Position = ButtonPosition.RightOutside Return symbolButton End Function ' Show or hide side buttons for gcComboFrame1 when comboBox1's selected index is changed. Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) For Each sideButton As SideButtonBase In Me.gcComboFrame1.SideButtons If sideButton.Name = Me.comboBox1.Text Then ' Shows the side button selected from comboBox1. sideButton.Visible = ButtonVisibility.ShowAlways Else ' Hides the side button that are not selected from comboBox1. sideButton.Visible = ButtonVisibility.NotShown End If Next ' Always show the DropDownButton. Me.gcComboFrame1.SideButtons("DropDownButton").Visible = ButtonVisibility.ShowAlways End Sub Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Me.gcComboFrame1.DroppedDown = True End Sub Private Sub GcComboFrame1_DropDownOpened(ByVal sender As Object, ByVal e As EventArgs) ' Change the SymbolButton's SymbolDirection after drop-down window has opened. TryCast(Me.gcComboFrame1.SideButtons("SymbolButton"), SymbolButton).SymbolDirection = SymbolDirection.Up End Sub ' Returns a SpinButton instance for gcComboFrame1. Private Function CreateSpinButton() As SideButtonBase Dim spinButton As New SpinButton() ' Specify a unique name for this button. spinButton.Name = "SpinButton" ' Set the Interval for spinButton. spinButton.Interval = 100 AddHandler spinButton.SpinUp, AddressOf SpinButton_SpinUp AddHandler spinButton.SpinDown, AddressOf SpinButton_SpinDown ' Not show spinButton in gcComboFrame1. spinButton.Visible = ButtonVisibility.NotShown Return spinButton End Function ' Increase the selected index of listBox1 when spin is down. Private Sub SpinButton_SpinDown(ByVal sender As Object, ByVal e As EventArgs) If Me.listBox1.SelectedIndex < Me.listBox1.Items.Count - 1 Then Me.listBox1.SelectedIndex += 1 Else Me.listBox1.SelectedIndex = Me.listBox1.Items.Count - 1 End If Me.textBox1.Text = Me.listBox1.SelectedItem.ToString() End Sub ' Decrease the selected index of listBox1 when spin is down. Private Sub SpinButton_SpinUp(ByVal sender As Object, ByVal e As EventArgs) If Me.listBox1.SelectedIndex > 0 Then Me.listBox1.SelectedIndex -= 1 Else Me.listBox1.SelectedIndex = 0 End If Me.textBox1.Text = Me.listBox1.SelectedItem.ToString() End Sub End Class End Namespace
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.Control
GrapeCity.Framework.Forms.FrameworkControl
GrapeCity.Framework.Views.Windows.ElementContainerControl
GrapeCity.Framework.Forms.ControlBase
GrapeCity.Win.Common.PlusPakControlBase
GrapeCity.Win.Common.PlusPakPickerBase
GrapeCity.Win.Containers.GcComboFrame
GrapeCity.Win.Pickers.GcColorPicker
GrapeCity.Win.Pickers.GcFontPicker
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2