万网独行 发表于 2012-4-23 23:01:14

刚做了个成绩单

刚学DELPHI,做了一个成绩单,不过文字不会居中。哪位大侠赐教!

乐yi忘忧 发表于 2012-5-20 22:57:36

标题不会居中也要售1鱼币?我帮你解决
procedure TForm1.TableDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);

const
AlignFlags:array of integer=
   (DT_LEFT oR DT_VCENTER OR DT_WORDBREAK OR DT_EXPANDTABS OR DT_NOPREFIX,
   DT_RIGHT OR DT_VCENTER OR DT_WORDBREAK OR DT_EXPANDTABS OR DT_NOPREFIX,
    DT_CENTER OR DT_VCENTER OR DT_WORDBREAK OR DT_EXPANDTABS OR DT_NOPREFIX);

var
s:string;
begin
inherited;
with Rect do
begin
    left:=left+2;
    top:=top+2;
    Right:=right-5;
end;
s:=Table.Cells;

if ((acol=0) and (arow<=table.RowCount)) or ((acol<=table.ColCount) and (arow=0)) then
begin
    Table.Canvas.Font.Style:=Table.Canvas.Font.Style+;
    Table.Canvas.Brush.Color:=Table.FixedColor;
    Table.Canvas.FillRect(rect);
    Drawtext(Table.Canvas.Handle,pchar(s),length(s),rect,AlignFlags);
end
else
//if   (acol=0   )   and   (arow> 0)   and   (arow <   Table.RowCount)   then
begin
Table.Canvas.FillRect(rect);
Drawtext(Table.Canvas.Handle,PChar(s),length(s),Rect,AlignFlags);
end;

Allen_bing 发表于 2012-5-22 09:18:16

z这还要钱啊

乐yi忘忧 发表于 2012-5-22 16:20:14

让赐教你的人拿钱给你:lol
页: [1]
查看完整版本: 刚做了个成绩单