2

This is how my drawing routine for TDBGrid component looks like. I am replacing values from database based on some rules:

void __fastcall TForm_Loadpoint_Details::DBGrid1DrawColumnCell(
  TObject *Sender, const TRect &Rect, int DataCol, TColumn *Column,
  TGridDrawState State)
{
    int row_index = ???;
    AnsiString text = GetCustomizedText(row_index, DataCol);
    DrawText(text);
}

However I don't know how to tell which row is currently being rendered? Without this knowledge i can't get data for displaying.

truthseeker
  • 1,220
  • 4
  • 25
  • 58

1 Answers1

0

You can use the Index or FieldNo property of the Column->Field object, or you can use an accessor class to access the protected TDBGrid::DataLink property and then use its ActiveRecord property.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • First two options are giving contradicting results for me (Index=1,FieldNo=3) but third option (TDBGrid::DataLink->ActiveRecord) seems to be OK. – truthseeker Dec 20 '11 at 12:03