DrawItemEventArgs.ForeColor Propriété
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Obtient la couleur de premier plan de l’élément dessiné.
public:
property System::Drawing::Color ForeColor { System::Drawing::Color get(); };
public System.Drawing.Color ForeColor { get; }
member this.ForeColor : System.Drawing.Color
Public ReadOnly Property ForeColor As Color
Valeur de propriété
Premier plan Color de l’élément dessiné.
Exemples
L’exemple de code suivant illustre l’utilisation de ce membre. Dans l’exemple, un gestionnaire d’événements signale l’occurrence de l’événement ListBox.DrawItem . Ce rapport vous aide à apprendre quand l’événement se produit et peut vous aider à déboguer.
Pour exécuter l’exemple de code, collez-le dans un projet qui contient une instance de type ListBox nommée ListBox1. Vérifiez ensuite que le gestionnaire d’événements est associé à l’événement 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
Remarques
Si l’état de l’élément est DrawItemState.Selected, la ForeColor valeur est définie SystemColors.HighlightTextsur . Si l’état de l’élément n’est pas Selected, la ForeColor propriété est définie sur SystemColors.WindowText.