PowerTools PlusPak for Windows Forms 8.0J
UseVisualStyleBackColor プロパティ (ColorPickerButton)
使用例 

視覚スタイルがサポートされている場合に、視覚スタイルを使用して背景を描画するかどうかを決定する値を取得または設定します。
構文
Public Property UseVisualStyleBackColor As Boolean
public bool UseVisualStyleBackColor {get; set;}

プロパティ値

背景が視覚スタイルを使用して描画される場合はtrue、それ以外の場合はfalse
解説
視覚スタイルは、コントロールの外観に関する規定です。たとえば、コントロールの色、サイズ、およびフォントを定義した視覚スタイルを使用して、アプリケーションのインタフェースに合わせたビジュアルインタフェースを構築できます。また、Windowsベースのすべてのアプリケーションに視覚スタイルを適用するしくみも用意されています。
使用例

次のサンプルコードは、UseVisualStyleBackColortrueに設定し、色採取操作の前の外観に戻します。

このサンプルコードは、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

参照

ColorPickerButton クラス
ColorPickerButton メンバ

Send Feedback