请教F1Book问题,如何代码隐藏用不着的行和列的那个字母,比如J,K...等,这样看起来就不像Excel(10分)

  • 主题发起人 主题发起人 net_morning
  • 开始时间 开始时间
N

net_morning

Unregistered / Unconfirmed
GUEST, unregistred user!
还有一个问题,insert一行的时候,这一行的格式与上一行相同,我在标题行下插入一行,结果这一行的格式跟标题相同了,这样看起来很难看,各位大侠是如何处理这种情况的?欢迎指点。
 
有吗 dbGridEh在事件里面自己划吧
 
跟据下面的这些代码你自个改改吧
procedure TFmdayquery.DBGridEh1GetCellParams(Sender: TObject;
Column: TColumnEh;
AFont: TFont;
var Background: TColor;
State: TGridDrawState);
begin
if ADOQuery1.FieldByName('Fqty').AsFloat < 0 then
begin
Afont.Color := clRed;
end
else
begin
Afont.Color := clWindowText;
end;
end;
 
写DrawColumnCell事件即可
只是需要在数据集中表明哪些记录是什么颜色的记录 这样画的时候才能处理
procedure ReBrushDBGridEh(Rect:TRect;Grid:TDBGridEH;Column:TColumnEH;
State:TGridDrawState;cColor:TColor;bFont:boolean=true);
var
B:TRect;
iLeft:integer;
sDisplayText : string;
begin
if gdSelected in State then
Exit;
if Column = nil then
sDisplayText := ''
else
if Column.Field = nil then
sDisplayText := ''
else
sDisplayText := Column.Field.DisplayText;
B:=Rect;
Grid.Canvas.Brush.Color := cColor;
case Column.Alignment of
taLeftJustify:
iLeft := B.Left + 2;
taRightJustify:
iLeft := B.Right - Grid.Canvas.TextWidth(sDisplayText) - 3;
else
iLeft := B.Left + (B.Right - B.Left) shr 1
- (Grid.Canvas.TextWidth(sDisplayText) shr 1);
end;
if bFont then
Grid.Canvas.Font.Color := clBlack;
Grid.Canvas.TextRect(B, iLeft, B.Top + 2, sDisplayText);
end;

procedure TForm1.DBGridEh1DrawColumnCell(Sender: TObject;
const Rect: TRect;
DataCol: Integer;
Column: TColumnEh;
State: TGridDrawState);
begin
if CDS_CheckPK.FieldByName('ZC_QUAN_GD').AsFloat>0 then
ReBrushDBGridEh(Rect,DBGridEh_PK,Column,State,$00F7F1F0);
end;
 
DBGridEh自带的例子DEMOS中有
 
正确答案
procedure TFManAttend.
DBGE_listGetCellParams(Sender: TObject;
Column: TColumnEh;
AFont: TFont;
var Background: TColor;
State: TGridDrawState);
begin
if (DBGE_list.SumList.RecNo mod 4 = 1) or (DBGE_list.SumList.RecNo mod 4 = 2) then
Background := $EAEAEA
else
Background := $FDFDFD;
end;
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
后退
顶部