Originariamente inviato da loris91
allora vorrei che selezionando con un singolo clic (al momento dell'secuzione) una cella singola della stringgrid l'intera riga di cui fa parte venisse colorata di un colore a mia scelta.....
Dai un'occhiata al codice seguente. Adattalo in base alle tue esigenze e soprattutto testalo bene, è solo un esempio:
codice:
int SelectedRow = -1;
void __fastcall TForm1::StringGrid1DrawCell(TObject *Sender, int ACol,
int ARow, TRect &Rect, TGridDrawState State)
{
if ((ACol >= StringGrid1->FixedCols) && (ARow >= StringGrid1->FixedRows))
{
if (ARow == SelectedRow)
StringGrid1->Canvas->Brush->Color = clYellow;
else
StringGrid1->Canvas->Brush->Color = clWhite;
StringGrid1->Canvas->FillRect(Rect);
StringGrid1->Canvas->Font->Color = clBlack;
String CellString = StringGrid1->Cells[ACol][ARow];
DrawText(StringGrid1->Canvas->Handle, CellString.c_str(), CellString.Length(), &Rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
}
}
void __fastcall TForm1::StringGrid1SelectCell(TObject *Sender, int ACol,
int ARow, bool &CanSelect)
{
SelectedRow = ARow;
StringGrid1->Refresh();
}
HTH,