天天看点

cxgrid动态多表头

function TForm15.CreateBand(View: TcxGridDBBandedTableView;

  BandCaption, ParentBandCaption: String): TcxGridBand;

var

  band: TcxGridBand;

begin

  Result := nil;

  if View = nil then exit;

  if ParentBandCaption <> '' then

    band := FMyList.Objects[FMyList.IndexOf(ParentBandCaption)] as TcxGridBand;

  Result := view.Bands.Add;

  with Result do

  begin

    Caption := BandCaption;

    if (BandCaption <> '') and (ParentBandCaption <> '') and (BandCaption <> ParentBandCaption) then

    begin

      Position.ColIndex := band.ColumnCount + 1;

      Position.BandIndex := band.Index;

    end else if (BandCaption = '') and (ParentBandCaption = '') then

      Position.ColIndex := FRootBandCount + 1;

      Position.BandIndex := -1;

      FMyBand := Result;

    end else begin

    end;

  end;

end;

继续阅读