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 *Senderint ACol,
int ARowTRect &RectTGridDrawState 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->HandleCellString.c_str()CellString.Length()&RectDT_SINGLELINE | DT_CENTER | DT_VCENTER);
}
}
void __fastcall TForm1::StringGrid1SelectCell(TObject *Senderint ACol,
int ARowbool &CanSelect)
{
SelectedRow = ARow;
StringGrid1->Refresh();
}
HTH,