在dbgrid中,怎么样使 我所选中的记录的整个一行 显示绿色背景(5分)

  • 主题发起人 主题发起人 ★蓝天★
  • 开始时间 开始时间

★蓝天★

Unregistered / Unconfirmed
GUEST, unregistred user!
我做了个数据库应用程序,所有文件保存 在aa这个文件夹下,当我把aa文件夹改为ab时,
程序就不能执行了,我用的是adoconnection. 在它的connectionstring中选了 jet4.0
然后就直接选上数据所在在路径。 我该怎么做?


在dbgrid中,怎么样使 我所选中的记录的整个一行 显示绿色背景?
 
procedure TFProduce.swDBGrid4DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
swDBGrid4.Canvas.Pen.Mode:=pmmask;
with swDBGrid4 do
begin
if (Column.Field.DataSet.FieldByName('First').AsInteger=0) then
begin
Canvas.Font.Color :=ClGreen;
Canvas.Brush.Color :=$00B0D0d0;
end;
swDBGrid4.DefaultDrawColumnCell(Rect,DataCol,Column,State);
end;
end;

end.
 
dbgrid 有个drawcolumncell 事件
state 表示以下三种状态
gdSelected The cell is currently selected.
gdFocused The cell has input focus.
gdFixed The cell is in the fixed region of the grid.
下面是我随手写的
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if state=gdselected then
dbgrid1.canvas.brush.color=clgreen
else
dbgrid1.canvas.brush.color:=clwhite;
end
end;
 
不知还有什么更好的办法吗、?
 
1.代码中动态给ConnectionString赋值。
2。如楼上所言。
 
后退
顶部