DrawItemEventArgs.State DrawItemEventArgs.State DrawItemEventArgs.State DrawItemEventArgs.State Property

定義

描画されている項目の状態を取得します。Gets the state of the item being drawn.

public:
 property System::Windows::Forms::DrawItemState State { System::Windows::Forms::DrawItemState get(); };
public System.Windows.Forms.DrawItemState State { get; }
member this.State : System.Windows.Forms.DrawItemState
Public ReadOnly Property State As DrawItemState

プロパティ値

描画されている項目の状態を表す DrawItemStateThe DrawItemState that represents the state of the item being drawn.

次のコード例では、このメンバーの使用を示します。The following code example demonstrates the use of this member. 例では、イベント ハンドラーが発生するときに報告、ListBox.DrawItemイベント。In the example, an event handler reports on the occurrence of the ListBox.DrawItem event. このレポートでは、イベントが発生してデバッグに役立つについて説明します。This report helps you learn when the event occurs and can assist you in debugging.

コード例を実行する型のインスタンスを含むプロジェクトに貼り付けることListBoxというListBox1します。To run the example code, paste it into a project that contains an instance of type ListBox that is named ListBox1. イベント ハンドラーに関連付けられていることを確認して、ListBox.DrawItemイベント。Then make sure that the event handler is associated with the ListBox.DrawItem event.

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列挙型メンバー。This property value can be a combination of the DrawItemState enumeration members. メンバーは、ビットごとの演算子を使用して組み合わせることができます。The members can be combined by using bitwise operators.

適用対象

こちらもご覧ください