zoukankan      html  css  js  c++  java
  • DBGRIDEH保存"显示标题"

    //edit by cxg. 2008-04-19 10:01:52
    //增加保存"显示标题"
    procedure TCustomDBGridEh.SaveColumnsLayoutProducer(ARegIni: TObject; Section:
      String; DeleteSection: Boolean);
    var
      I: Integer;
      S: String;
    begin
      if (ARegIni is TRegIniFile) then
        TRegIniFile(ARegIni).EraseSection(Section)
      else if DeleteSection then
        TCustomIniFile(ARegIni).EraseSection(Section);

      with Columns do
      begin
        for I := 0 to Count - 1 do
        begin
          if ARegIni is TRegIniFile then
            TRegIniFile(ARegIni).WriteString(Section, Format('%s.%s', [Name, Items[I].FieldName]),
              Format('%d,%d,%d,%d,%d,%d,%d,%s', [Items[I].Index, Items[I].Width, Integer(Items[I].Title.SortMarker),
              Integer(Items[I].Visible), Items[I].Title.SortIndex, Items[I].DropDownRows, Items[I].DropDownWidth,Items[I].Title.Caption]))
          {
            TRegIniFile(ARegIni).WriteString(Section, Format('%s.%s', [Name, Items[I].FieldName]),
              Format('%d,%d,%d,%d,%d,%d,%d', [Items[I].Index, Items[I].Width, Integer(Items[I].Title.SortMarker),
              Integer(Items[I].Visible), Items[I].Title.SortIndex, Items[I].DropDownRows, Items[I].DropDownWidth]))
          }
          else
          begin
            S := Format('%d,%d,%d,%d,%d,%d,%d,%s', [Items[I].Index, Items[I].Width, Integer(Items[I].Title.SortMarker),
              Integer(Items[I].Visible), Items[I].Title.SortIndex, Items[I].DropDownRows, Items[I].DropDownWidth,Items[i].Title.Caption]);
          {
            S := Format('%d,%d,%d,%d,%d,%d,%d', [Items[I].Index, Items[I].Width, Integer(Items[I].Title.SortMarker),
              Integer(Items[I].Visible), Items[I].Title.SortIndex, Items[I].DropDownRows, Items[I].DropDownWidth]);
          }
            if S <> '' then
            begin
              if ((S[1] = '"') and (S[Length(S)] = '"')) or
              ((S[1] = '''') and (S[Length(S)] = '''')) then
                S := '"' + S + '"';
            end;
          end;
          if ARegIni is TCustomIniFile
            then TCustomIniFile(ARegIni).WriteString(Section, Format('%s.%s', [Name, Items[I].FieldName]), S);
        end;
      end;
    end;

    //edit by cxg. 2008-04-19 10:02:13
    //增加恢复"显示标题"
    procedure TCustomDBGridEh.RestoreColumnsLayoutProducer(ARegIni: TObject;
      Section: String; RestoreParams: TColumnEhRestoreParams);
    type
      TColumnInfo = record
        Column: TColumnEh;
        EndIndex: Integer;
        SortMarker: TSortMarkerEh;
        SortIndex: Integer;
      end;
      PColumnArray = ^TColumnArray;
      TColumnArray = array[0..0] of TColumnInfo;
    const
      Delims = [' ', ','];
    var
      I, J: Integer;
      S: string;
      ColumnArray: array of TColumnInfo;
      AAutoFitColWidth: Boolean;
    begin
      AAutoFitColWidth := False;
      BeginUpdate;
      try
        if (AutoFitColWidths) then
        begin
          AutoFitColWidths := False;
          AAutoFitColWidth := True;
        end;
        with Columns do
        begin
          SetLength(ColumnArray, Count);
          try
            for I := 0 to Count - 1 do
            begin
              if (ARegIni is TRegIniFile)
                then S := TRegIniFile(ARegIni).ReadString(Section, Format('%s.%s', [Name, Items[I].FieldName]), '')
                else S := TCustomIniFile(ARegIni).ReadString(Section, Format('%s.%s', [Name, Items[I].FieldName]), '');
              ColumnArray[I].Column := Items[I];
              ColumnArray[I].EndIndex := Items[I].Index;
              if S <> '' then
              begin
                ColumnArray[I].EndIndex := StrToIntDef(ExtractWord(1, S, Delims),
                  ColumnArray[I].EndIndex);
                if (crpColWidthsEh in RestoreParams) then
                  Items[I].Width := StrToIntDef(ExtractWord(2, S, Delims),
                    Items[I].Width);
                if (crpSortMarkerEh in RestoreParams) then
                  Items[I].Title.SortMarker := TSortMarkerEh(StrToIntDef(ExtractWord(3, S, Delims),
                    Integer(Items[I].Title.SortMarker)));
                if (crpColVisibleEh in RestoreParams) then
                  Items[I].Visible := Boolean(StrToIntDef(ExtractWord(4, S, Delims), Integer(Items[I].Visible)));
                if (crpSortMarkerEh in RestoreParams) then
                  ColumnArray[I].SortIndex := StrToIntDef(ExtractWord(5, S, Delims), 0);
                if (crpDropDownRowsEh in RestoreParams) then
                  Items[I].DropDownRows := StrToIntDef(ExtractWord(6, S, Delims), Items[I].DropDownRows);
                if (crpDropDownWidthEh in RestoreParams) then
                  Items[I].DropDownWidth := StrToIntDef(ExtractWord(7, S, Delims), Items[I].DropDownWidth);
                Items[I].Title.Caption:=ExtractWord(8, S, Delims);//add by cxg
              end;
            end;
            if (crpSortMarkerEh in RestoreParams) then
              for I := 0 to Count - 1 do
                Items[I].Title.SortIndex := ColumnArray[I].SortIndex;
            if (crpColIndexEh in RestoreParams) then
              for I := 0 to Count - 1 do
                for J := 0 to Count - 1 do
                  if ColumnArray[J].EndIndex = I then
                  begin
                    ColumnArray[J].Column.Index := ColumnArray[J].EndIndex;
                    Break;
                  end;

          finally
            //FreeMem(Pointer(ColumnArray));
            SetLength(ColumnArray, 0);
          end;
        end;
      finally
        EndUpdate;
        if (AAutoFitColWidth = True)
          then AutoFitColWidths := True
          else LayoutChanged;
      end;
    end;
     

  • 相关阅读:
    gimp 语言设置
    gnome 3.4 评测
    linux 添加PATH路径
    永中office2012 linux版 使用初步感受
    Bio per常规用法(1、读取序列)
    blast程序 介绍 简介
    genewise运行过程中遇到的错误及其解决方法
    gnome3 隐藏标题栏
    Bio per常规用法(2、翻译蛋白)
    genewise 编译过程中遇到的 getline冲突
  • 原文地址:https://www.cnblogs.com/hnxxcxg/p/2940885.html
Copyright © 2011-2022 走看看