http://www.swissdelphicenter.ch/en/showcode.php?id=1653
http://delphi.ktop.com.tw/board.php?cid=30&fid=66&tid=38801
type TAccessDBGrid = class(TDBGrid); ... ...
再於 DBGrid 的 onDrawColumnCell 事件內寫入下述程式碼:
procedure TForm2.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); var S1, S2: String; begin with TAccessDBGrid(DBGrid1) do begin // 指定標題欄高度 RowHeights[0] := 32; Canvas.Brush.Style := bsClear; // Column Titles case Column.Index of 0: begin Column.Title.Caption := ''; S1 := 'Row 1'; S2 := 'Row 2'; end; 1: begin Column.Title.Caption := ''; S1 := 'Row 3'; S2 := 'Row 4'; end; end; // write title: Canvas.TextOut(Rect.Left+2, 2, S1); Canvas.TextOut(Rect.Left+2, 16, S2); end; end;
沒有留言:
張貼留言