在DBGRID的DrawColumnCell事件加入 if status = 1then begin DBGrid1.Canvas.Brush.Color := 显示灰色; end else begin DBGrid1.Canvas.Brush.Color := 显示白色; end; DBGrid.DefaultDrawColumnCell(Rect,DataCol,Column,State);
字段 status 可以直接写 if status=1 then …… 吗? 是不是要写 if clientdataset.FieldByName('status').AsString='1' then我用的是三层结构的 客户端的Dbgrid想有这样的显示效果
我不知道“status”是个什么东东,如果是表里的一个字段,应该按你的那样写。
我在DBGRID的DrawColumnCell事件加入if iclientdataset1.FieldByName('status').AsString='1' then begin DBGrid1.Canvas.Brush.Color:=cl3Dlight end else begin DBGrid1.Canvas.Brush.Color :=clwindow; end; //DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State); DBGrid1.DefaultDrawDataCell(Rect,Field,State);但是结好像还不行 Dbgrid没变化 是不是有什么属性没改好 ?>
if status = 1then
begin
DBGrid1.Canvas.Brush.Color := 显示灰色;
end
else
begin
DBGrid1.Canvas.Brush.Color := 显示白色;
end;
DBGrid.DefaultDrawColumnCell(Rect,DataCol,Column,State);
是不是要写 if clientdataset.FieldByName('status').AsString='1' then我用的是三层结构的
客户端的Dbgrid想有这样的显示效果
begin
DBGrid1.Canvas.Brush.Color:=cl3Dlight
end
else
begin
DBGrid1.Canvas.Brush.Color :=clwindow;
end;
//DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
DBGrid1.DefaultDrawDataCell(Rect,Field,State);但是结好像还不行
Dbgrid没变化
是不是有什么属性没改好 ?>
查询出来的结果不能显示
即,查询出3条记录的时候 Dbgrid显示3行 但是没数据
查出有10条记录的时候 Dbgrid显示10行 但是各格里没有数据这是什么原因 ?
不是DBGrid1.DefaultDrawDataCell(Rect,Field,State);如果用DefaultDrawDataCell需要在OnDrawDataCell里面写。
在IF语句加上
DBGrid1.Canvas.Font.Color:=clBlack;试试。