Bonjour à tous
J'aimerais savoir si c'est possible de changer la police d'affichage d'une ligne d'un checkListBox.
Merci d'avance pour votre aide.
Version imprimable
Bonjour à tous
J'aimerais savoir si c'est possible de changer la police d'affichage d'une ligne d'un checkListBox.
Merci d'avance pour votre aide.
Bonsoir,
Comme dans bien d'autre composant de type 'Grille' ou 'Liste' (je généralise), il te faut gérer le dessin des éléments :
.dans le OnDrawItem de l'objet:
.mettre la propriété Style du TCheckListBox a lbOwnerDrawFixed.Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 void __fastcall TForm2::CheckListBox1DrawItem(TWinControl *Control, int Index, TRect &Rect, TOwnerDrawState State) { TCanvas *cv = CheckListBox1->Canvas; cv->FillRect(Rect); if ((Index%2)!= 0) { cv->Brush->Color = clMoneyGreen; } if (State.Contains(odSelected)) { cv->Font->Color = clRed; cv->Font->Style = TFontStyles() << fsBold << fsUnderline; cv->DrawFocusRect(Rect); } cv->TextRect(Rect, Rect.Left + 2, Rect.Top, CheckListBox1->Items->Strings[Index]); }
En espérant t'aider,
@ + ;)
Je vais regarder ca, merci