Bonjour,
Voila je cherche � colorer l'ensemble d'une colonne d'un StringGrid. Mon probl�me c'est que la position de cette colonne est amen�e � varier.
J'ai une fonction de recherche que j'ai cr��e qui me permet de retrouver la chaine de caract�re dans le tableau :
Celle ci fonctionne tr�s bien.
Code : S�lectionner tout - Visualiser dans une fen�tre � part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 TRect TForm_Tab_Clients::Recherche2(AnsiString Element_recherche) { for (int i = 0;i < StringGrid->ColCount ;i++) { for (int j = 0; j<StringGrid->RowCount ;j++) { if (Element_recherche == StringGrid->Cells[i][j])//si la valeur courante est égale à la valeur suivante { myRect2.Left = i; myRect2.Top = 1; myRect2.Right = i; myRect2.Bottom = StringGrid->RowCount; return myRect2; } } } }
J'ai cr�� une variable bool�enne qui me permet de savoir si mon fichier est charg� dans ma StringGrid.
Ensuite dans ma m�thode StringGridDrawCell j'ai �a:
Code : S�lectionner tout - Visualiser dans une fen�tre � part bool Fichier_Charge = false;
Mon probl�me c'est que je n'ai aucune couleur qui apparait dans mon tableau.
Code : S�lectionner tout - Visualiser dans une fen�tre � part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 void __fastcall TForm_Tab_Clients::StringGridDrawCell(TObject *Sender, int ACol, int ARow, TRect &Rect, TGridDrawState State) { if(Fichier_Charge) { Rect = Recherche2(colcolor); int i = Rect.Left; if((ACol == i) && (ARow != 0)) { StringGrid->Canvas->Brush->Color = clRed; StringGrid->Canvas->TextRect(Rect, Rect.Left , Rect.Top , StringGrid->Cells[ACol][ARow]); } } }
Je ne comprend pas pourquoi.
Merci par avance pour vos suggestions...
Partager