couleur colonne StringGrid
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 :
Code:
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;
}
}
}
} |
Celle ci fonctionne très bien.
J'ai créé une variable booléenne qui me permet de savoir si mon fichier est chargé dans ma StringGrid.
Code:
bool Fichier_Charge = false;
Ensuite dans ma méthode StringGridDrawCell j'ai ça:
Code:
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]);
}
}
} |
Mon problème c'est que je n'ai aucune couleur qui apparait dans mon tableau.
Je ne comprend pas pourquoi.
Merci par avance pour vos suggestions...