如何用stringgrid实现第一行标题的竖列显示呀,

来源:互联网 发布:互联网数据分析师年薪 编辑:程序博客网 时间:2024/05/01 11:14
自画,把你的标题行高设置到合适的高度,然后在DrawCell事件里写
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
var
  x,y,i,h: integer;
  grd: TStringGrid;
  bt,bt1: string;
begin
  if ACol + ARow <> 0 then Exit;
  grd := Sender as TStringGrid;
  bt := grd.cells[ACol, ARow];
  if trim(bt) = '' then exit;
  h := grd.Canvas.TextHeight(bt);
  i := 1;
  x := rect.Left + 5;
  y := rect.Top + 2;
  grd.Canvas.Brush.Color := clBtnface;
  grd.Canvas.FillRect(Rect);
  while i <= length(bt) do
  begin
    bt1 := copy(bt, i, 2);
    grd.Canvas.TextOut(x,y, bt1);
    i := i + 2;
    y := y + h;
  end;
end;  
 
原创粉丝点击