DrawItemEventArgs.State Свойство

Определение

Получает состояние изображаемого элемента.

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

Значение свойства

Объект DrawItemState, представляющий состояние изображаемого элемента.

Примеры

В следующем примере кода показано использование этого элемента. В этом примере обработчик событий сообщает о возникновении ListBox.DrawItem события. Этот отчет поможет вам узнать, когда происходит событие, и поможет вам в отладке.

Чтобы выполнить пример кода, вставьте его в проект, содержащий экземпляр типа ListBox с именем ListBox1. Затем убедитесь, что обработчик событий связан с событием 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 элементов перечисления. Элементы можно объединять с помощью побитовых операторов.

Применяется к

См. также раздел