Board index » cppbuilder » How can I set the dbgrid column 's default value?

How can I set the dbgrid column 's default value?

How can I set the dbgrid column 's default value?
Can I set the dbgrid row's color?
Thanks advance?
 

Re:How can I set the dbgrid column 's default value?


Provide a handler for the DBGrid's OnDrawColumnCell event.

//---------------------------------------------------------------------------

void __fastcall TForm1::DBGrid1DrawColumnCell(TObject *Sender,
      const TRect &Rect, int DataCol, TColumn *Column,
      TGridDrawState State)
{
if (DataCol <= 2 || DataCol == DBGrid1->Columns->Count-1)
   // set color for first 3 and rightmost column
  Column->Color = clRed;
else
if (DataCol == 3)
    // set color for 4th column
  Column->Color = clYellow;
else
    // set color for all other columns
  Column->Color = clGreen;

Quote
}

Other Threads