In the design process, sometimes a large amount of data, field more time, just click on the cell may be a field of data mistakenly operation (such as data wrong line), this will think of this problem, the solution is as follows: Click on the cell to change the current row color.
First DBGrid the property to do the next set (in fact, also dbgrid default properties)
Dbgrid1->options->dgediting=true
Dbgrid1->options->dgrowselect=false
First, before the implementation to do the following definition
Type
Tmydbgrid=class (TDBGrid);
Second, the Ondrawcolumncell operation in the DBGrid
Procedure Tfrm_hetong. Dbgrid2drawcolumncell (Sender:tobject;
Const Rect:trect; Datacol:integer; Column:tcolumn;
State:tgriddrawstate);
Begin
With Tmydbgrid (Sender) do
Begin
If Datalink.activerecord=row-1 Then
Begin
Canvas.font.color:=clwhite;
canvas.brush.color:=$00800040;
End
Else
Begin
Canvas.brush.color:=color;
Canvas.font.color:=font.color;
End
Defaultdrawcolumncell (rect,datacol,column,state);
End
End
In DBGrid, click a cell to select an entire row, double-click and edit the cell