如何在OnDrawColumnCell事件中获取行号?
这就是我的 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);
}
但是我不知道如何判断当前正在呈现哪一行?如果没有这些知识,我无法获取用于显示的数据。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
Column->Field
对象的Index
或FieldNo
属性,也可以使用访问器类来访问受保护的 < code>TDBGrid::DataLink 属性,然后使用其ActiveRecord
属性。You can use the
Index
orFieldNo
property of theColumn->Field
object, or you can use an accessor class to access the protectedTDBGrid::DataLink
property and then use itsActiveRecord
property.