DrawItemEventArgs.State プロパティ

定義

描画されている項目の状態を取得します。

C#
public System.Windows.Forms.DrawItemState State { get; }

プロパティ値

描画されている項目の状態を表す DrawItemState

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

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

C#
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" );
}

注釈

このプロパティ値には、列挙メンバーの DrawItemState 組み合わせを指定できます。 メンバーは、ビットごとの演算子を使用して結合できます。

適用対象

製品 バージョン
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

こちらもご覧ください