unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, DBGrids, DB, cxGraphics,cxGridLevel, cxClasses, cxControls,
  cxGridCustomView, cxGridCustomTableView, cxGridTableView,
  cxGridDBTableView, cxGrid, ExtCtrls, ADODB, QLDBLkp, cxStyles,
  cxStorage,
  cxGridCommon,
  cxCustomData, cxData,cxEdit,cxLookAndFeels, StdCtrls;type
  TForm1 = class(TForm)
    Panel1: TPanel;
    cxGrid1: TcxGrid;
    gridMain: TcxGridDBTableView;
    cxGrid1Level1: TcxGridLevel;
    DataSource1: TDataSource;
    ADOConnection1: TADOConnection;
    ADOTable1: TADOTable;
    ADOTable2: TADOTable;
    DataSource2: TDataSource;
    cxStyleRepository1: TcxStyleRepository;
    cxStyle1: TcxStyle;
    cxStyle2: TcxStyle;
    cxStyleRepository2: TcxStyleRepository;
    cxStyle3: TcxStyle;
    gridMainid: TcxGridDBColumn;
    gridMaindt: TcxGridDBColumn;
    gridMaincode: TcxGridDBColumn;
    Memo1: TMemo;
    procedure gridMainCustomDrawCell(Sender: TcxCustomGridTableView;
      ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo;
      var ADone: Boolean);
    private
    { Private declarations }
   public
  function DrawFullGrid(GridTableView: TcxCustomGridTableView; ACanvas: TcxCanvas;  AViewInfo: TcxGridTableDataCellViewInfo): Boolean;
  protected
   { Public declarations }
  end;
var
  Form1: TForm1;implementation{$R *.dfm}
function TForm1.DrawFullGrid(GridTableView: TcxCustomGridTableView;
  ACanvas: TcxCanvas;
   AViewInfo: TcxGridTableDataCellViewInfo): Boolean;
var
  i: Integer;
  lMaxRow: Integer;
  Rect1: TRect;
  procedure DrawUltraBandButton(var ARect: TRect; ABrush: HBRUSH);
  begin
    DrawEdge(ACanvas.Handle, ARect, BDR_SUNKENOUTER, BF_BOTTOM or BF_RIGHT or
      BF_FLAT or BF_ADJUST);
    ACanvas.Brush.Color := ABrush;
    ACanvas.FillRect(ARect);
    InflateRect(ARect, -1, 0);
  end;  procedure DrawBandButton(var ARect: TRect; ABrush: HBRUSH; ALookAndFeel:
    TCxLookAndFeel);
  begin
    ACanvas.Brush.Color := ABrush;
    if ALookAndFeel.Kind = lfStandard then
    begin
      DrawEdge(ACanvas.Handle, ARect, BDR_RAISEDINNER, BF_BOTTOMRIGHT or
        BF_ADJUST);
      DrawEdge(ACanvas.Handle, ARect, BDR_RAISEDINNER, BF_TOPLEFT or BF_ADJUST);
      ACanvas.FillRect(ARect);
    end
    else
    begin
      if ALookAndFeel.Kind = lfUltraFlat then
      begin
        FrameRect(ACanvas.Handle, ARect, GetSysColorBrush(COLOR_BTNSHADOW));
        InflateRect(ARect, -1, -1);
      end
      else
        DrawEdge(ACanvas.Handle, ARect, BDR_RAISEDINNER, BF_RECT or BF_ADJUST);
      ACanvas.FillRect(ARect);
      InflateRect(ARect, -1, 0);
    end;
  end;
begin
  i := 0;
  ACanvas.Canvas.Lock;
  //计算最多画多少行
  while (AViewInfo.editBounds.Bottom - AViewInfo.editBounds.Top + 2) * i <=cxGrid1.Height do
    inc(i);
  lMaxRow := i - 3; //计算画多少行
   //开始画表格
  if AViewInfo.GridRecord.Index = GridTableView.ViewData.RecordCount - 1 then
  begin
    for i := 1 to lMaxRow - AViewInfo.GridRecord.Index do
    begin
      //画表格
      Rect1.Top := AViewInfo.EditBounds.Top - 1 + (AViewInfo.EditBounds.Bottom - AViewInfo.EditBounds.Top) * i;
      Rect1.Bottom := AViewInfo.EditBounds.Bottom + (AViewInfo.EditBounds.Bottom - AViewInfo.EditBounds.Top) * i;
      Rect1.Left := AViewInfo.EditBounds.Left - 1;
      Rect1.Right := AViewInfo.EditBounds.Right + 1;
      ACanvas.Canvas.Brush.Color := clSilver;
      ACanvas.Canvas.FrameRect(Rect1);
      memo1.Lines.Add('Rect1.Top:'+InttoStr(Rect1.Top));
      memo1.Lines.Add('Rect1.Bottom: '+InttoStr(Rect1.Bottom ));
      memo1.Lines.Add('Rect1.Left:'+InttoStr(Rect1.Left));
      memo1.Lines.Add('Rect1.Right:'+InttoStr(Rect1.Right));
      memo1.Lines.Add('I:'+InttoStr(i));
      memo1.Lines.Add('lMaxRow:'+InttoStr(lMaxRow));
      //画标尺列
//      if (Indicator in Sender.OptionsView) then
//      begin
//        AViewInfo.Bounds.Left := 0;
//        AViewInfo.Bounds.Right := 12;
//        AViewInfo.Bounds.Top := AViewInfo.Bounds.Top + 1;
       // if i = 1 then
//          AViewInfo.Bounds.Top := AViewInfo.Bounds.Top + 1;
//        if cxGrid1.LookAndFeel.Kind = lfUltraFlat then
//          DrawUltraBandButton(AViewInfo.Bounds, AViewInfo.Style.Color)
//        else
//          DrawBandButton(AViewInfo.Bounds, AViewInfo.Style.Color, cxGrid1.LookAndFeel);
//      //aend;
    end;
  end;
  ACanvas.Canvas.Unlock;
  Result:=True;
end;procedure TForm1.gridMainCustomDrawCell(Sender: TcxCustomGridTableView;
  ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo;
  var ADone: Boolean);
begin
 // inherited;
  //ADone:=
  DrawFullGrid(Sender,ACanvas,AViewInfo);
end;end.
程序是想要实现CXGRID画表格的功能,因为CXGRID只画出记录条数的表格线,当记录不满一表格时特别难看,所以我想通过自画把空白的部分补齐,
哪位帮我看一下这段程序有什么问题,我执行出来的结果,看着他在那画表格,但马上就没有了???解决问题的奉上我修改的CXGRID表格组件,实现中国式金额显示及插入自定控件
详细功能可以看一下下面的图片
http://www.wujihong.com/1.jpg
http://www.wujihong.com/2.jpg
http://www.wujihong.com/3.jpg