GrapeCity.Win.Pickers 名前空間 > GcColorPicker クラス : HideSelection プロパティ |
次のサンプルコードは、色を選択するためのGcColorPickerコントロールを作成して使用する方法を示します。また、HideSelectionプロパティの使用方法も示します。この例を実行するには、button1という名前のSystem.Windows.Forms.Buttonインスタンスを含むSystem.Windows.Forms.Formに以下のコードを追加し、ここで作成したメソッドをコンストラクターまたはフォーム上の別のメソッドから呼び出す必要があります。
private void CreateMyGcColorPicker() { // Create an instance of GcColorPicker control. GcColorPicker gcColorPicker = new GcColorPicker(); // Initialize the Name and Location of the gcColorPicker. gcColorPicker.Name = "gcColorPicker"; gcColorPicker.Location = new Point(10, 50); // Shows and sets the automatic color in the drop-down window. gcColorPicker.ShowAutomaticColor = true; gcColorPicker.AutomaticColor = SystemColors.WindowText; // Shows and sets the no-fill color in the drop-down window. gcColorPicker.ShowNoFillColor = true; gcColorPicker.NoFillColor = SystemColors.Window; // Remains hightlight the text of gcColorPicker when gcColorPicker lost focus. gcColorPicker.HideSelection = false; // Hightlight the text of gCcColorPicker when gcColorPicker gets focus. gcColorPicker.HighlightText = true; gcColorPicker.SelectedColorChanged += new EventHandler(GcColorPicker_SelectedColorChanged); // adds gcColorPicker to the form. this.Controls.Add(gcColorPicker); } // Change the button1's back color to the selected color of gcColorPicker. private void GcColorPicker_SelectedColorChanged(object sender, EventArgs e) { this.button1.BackColor = (sender as GcColorPicker).SelectedColor; }
Private Sub CreateMyGcColorPicker() ' Create an instance of GcColorPicker control. Dim gcColorPicker As New GcColorPicker() ' Initialize the Name and Location of the gcColorPicker. gcColorPicker.Name = "gcColorPicker" gcColorPicker.Location = New Point(10, 50) ' Shows and sets the automatic color in the drop-down window. gcColorPicker.ShowAutomaticColor = True gcColorPicker.AutomaticColor = SystemColors.WindowText ' Shows and sets the no-fill color in the drop-down window. gcColorPicker.ShowNoFillColor = True gcColorPicker.NoFillColor = SystemColors.Window ' Remains hightlight the text of gcColorPicker when gcColorPicker lost focus. gcColorPicker.HideSelection = False ' Hightlight the text of gCcColorPicker when gcColorPicker gets focus. gcColorPicker.HighlightText = True AddHandler gcColorPicker.SelectedColorChanged, AddressOf GcColorPicker_SelectedColorChanged ' adds gcColorPicker to the form. Me.Controls.Add(gcColorPicker) End Sub ' Change the button1's back color to the selected color of gcColorPicker. Private Sub GcColorPicker_SelectedColorChanged(ByVal sender As Object, ByVal e As EventArgs) Me.button1.BackColor = TryCast(sender, GcColorPicker).SelectedColor End Sub
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