DrawItemEventArgs.BackColor プロパティ

定義

描画されている項目の背景色を取得します。

public:
 property System::Drawing::Color BackColor { System::Drawing::Color get(); };
public System.Drawing.Color BackColor { get; }
member this.BackColor : System.Drawing.Color
Public ReadOnly Property BackColor As Color

プロパティ値

描画されている項目の背景色を示す Color

次のコード例では、このメンバーの使用方法を示します。 この例では、イベント ハンドラーがイベントの ListBox.DrawItem 発生を報告します。 このレポートは、イベントが発生したタイミングを知るのに役立ち、デバッグに役立ちます。

コード例を実行するには、 という名前ListBox1の 型ListBoxのインスタンスを含むプロジェクトに貼り付けます。 次に、イベント ハンドラーが イベントに ListBox.DrawItem 関連付けられていることを確認します。

private void ListBox1_DrawItem(Object sender, DrawItemEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "BackColor", e.BackColor );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Bounds", e.Bounds );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Font", e.Font );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "ForeColor", e.ForeColor );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Graphics", e.Graphics );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Index", e.Index );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "State", e.State );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "DrawItem Event" );
}
Private Sub ListBox1_DrawItem(sender as Object, e as DrawItemEventArgs) _ 
     Handles ListBox1.DrawItem

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "BackColor", e.BackColor)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Bounds", e.Bounds)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Font", e.Font)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "ForeColor", e.ForeColor)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Graphics", e.Graphics)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Index", e.Index)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "State", e.State)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"DrawItem Event")

End Sub

注釈

項目の状態が の場合、 DrawItemState.SelectedBackColor は にSystemColors.HighlightText設定されます。 アイテムの状態が でない Selected場合、 BackColor プロパティは に SystemColors.Window設定されます。

適用対象

こちらもご覧ください