2

这就是我为 TDBGrid 组件绘制例程的样子。我正在根据一些规则替换数据库中的值:

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);
}

但是我不知道如何判断当前正在渲染哪一行?如果没有这些知识,我将无法获得用于显示的数据。

4

1 回答 1

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.

于 2011-12-20T09:30:11.373 回答