GrapeCity.Win.Common 名前空間 > ColorPickerButton クラス : Image プロパティ |
次のサンプルコードは、Imageを色採取操作の前のイメージに設定します。
このサンプルコードは、GrapeCity.Win.Containers.GcComboFrameクラスの概要に示されている詳細なコード例の一部を抜粋したものです。その元の例では、最初にcomboBox1からColorPickerButton項目を選択してgcComboFrame1にColorPickerButtonを表示し、次にColorPickerButtonを使用して画面から色を採取できます。
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; }
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
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