关于dbgrid问题(100分)

  • 主题发起人 土拨鼠
  • 开始时间

土拨鼠

Unregistered / Unconfirmed
GUEST, unregistred user!
在DBgrid中用鼠标选择可以使选中一行,使其高亮显示。如果通过定位某条数据,则
该数据行在DBgrid中显示并没有高亮显示,只有一个三角移制该条记录。
求教各位高手,如何使其也能高亮显示整行数据。谢谢!
 
在这个事件DrawColumnCell写下面的代码
procedure Tbaseinputfrm.DBGridTopDrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
var
RectTemp : TRect;
begin
inherited;
with DBGridTop do
begin
if State <> [gdSelected, gdFocused] then
begin
if (AdoQinput.RecNo mod 2)=0 then
Canvas.Brush.Color := rgb(239,247,255)
else
Canvas.Brush.Color := rgb(222,237,252);
end;
DefaultDrawColumnCell(Rect, DataCol, Column, State);


if gdSelected in state then
begin
RectTemp := Rect;
Canvas.Brush.Color:=RGB(160,191,223);
Canvas.Font.Color := ClBlack;
DefaultDrawColumnCell(Rect, DataCol, Column, State);
Canvas.Brush.Color := RGB(0,0,0);
Canvas.FrameRect(RectTemp);
end;
end;
end;
 
把dbgird的 Options下的dgAlwaysShowSelection的属性设为True就可以了
 
同意lailai
 
多人接受答案了。
 
顶部