Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Delphi TDBGrid onDrawColumnCell第一行问题_Delphi_Grid - Fatal编程技术网

Delphi TDBGrid onDrawColumnCell第一行问题

Delphi TDBGrid onDrawColumnCell第一行问题,delphi,grid,Delphi,Grid,我已经为TDBGRID的OnDrawColumnCell编写了一个过程。当我将鼠标停留在网格的第一行上时,OnDrawColumnCell将被连续调用,并且从不停止。有办法解决这个问题吗 procedure TInvoicesUnpaidGrid.dbgDrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State:TGridDrawState); begin if (d

我已经为TDBGRID的OnDrawColumnCell编写了一个过程。当我将鼠标停留在网格的第一行上时,OnDrawColumnCell将被连续调用,并且从不停止。有办法解决这个问题吗

procedure TInvoicesUnpaidGrid.dbgDrawColumnCell(Sender: TObject;
const Rect:   TRect; DataCol: Integer; Column: TColumn; 
State:TGridDrawState);
begin
if (dc.DataSet.FieldValues['Overdue']=1) then
  dbg.Canvas.Font.Color:=clRed;
end;

您发布的代码中没有任何内容会导致这种行为。它在代码的其他地方。您是否有任何其他与网格相关的事件?鼠标相关事件中有任何内容吗?没有其他与网格相关的事件。这确实非常奇怪,只发生在第一行。正如我所说,您发布的代码中没有任何东西会导致这种行为。(我有许多CRUD应用程序使用TDBGrid显示数据,用各种行颜色表示状态,并且在所有应用程序中使用非常相似的代码,没有问题。)您是否有任何与鼠标相关的事件(不仅仅是DBGrid,还有任何与鼠标相关的事件)?请查看TDBGrid的选项属性组。dgEditing是否设置为True?如果是这样,将其设置为false是否会阻止您看到的行为?在我的测试项目中,如果dgEditing=True,则插入CustomDrawCell事件的断点将持续中断。您如何观察此行为?调试时,您没有在该事件代码上设置断点并用IDE覆盖网格吗?这可能会导致网格一次又一次地重新绘制。