zoukankan      html  css  js  c++  java
  • DBGridEh(RestoreGridLayoutIni)用法

    var
      MyReg:TRegIniFile;
    begin
      MyReg:=TRegIniFile.Create;
      try
        MyReg.OpenKey('MyGridInfo',True);
        DBGridEh1.SaveGridLayout(MyReg);
      finally
        MyReg.CloseKey;
        FreeAndNil(MyReg);
      end;
    end;

    //恢复:
    var
      MyReg:TRegIniFile;
    begin
      MyReg:=TRegIniFile.Create;
      try
        MyReg.OpenKey('MyGridInfo',True);
        DBGridEh1.RestoreGridLayout(MyReg,[grpColIndexEh, grpColWidthsEh, grpSortMarkerEh, grpColVisibleEh,
        grpRowHeightEh, grpDropDownRowsEh, grpDropDownWidthEh]);
      finally
        MyReg.CloseKey;
        FreeAndNil(MyReg);
      end;
    end;

    =====================================================================

    procedure TForm1.Button1Click(Sender: TObject);
    var
      iniFile:TIniFile;
    begin
      DBGridEh1.SaveGridLayoutIni('C:\test.ini','test',false);
    end;

    procedure TForm1.Button2Click(Sender: TObject);
    var
      RestoreParams:TDBGridEhRestoreParams;
    begin
      RestoreParams:=[grpColIndexEh, grpColWidthsEh, grpSortMarkerEh,
        grpColVisibleEh, grpRowHeightEh, grpDropDownRowsEh, grpDropDownWidthEh];
      DBGridEh1.RestoreGridLayoutIni('C:\test.ini','test',RestoreParams);
    end;

    ====================================================

    procedure TFrmColSelect.SaveGridLayOut;
    var
      Ini: TIniFile;
    begin
      if CheckBox1.Checked then
        Grid.SaveGridLayoutIni(ExtractFilePath(Application.ExeName) + '\Grid.ini',
          Owner.ClassName + '$' + Name, true)
      else
      begin
        Ini := TIniFile.Create(ExtractFilePath(Application.ExeName) + '\Grid.ini');
        try
          Ini.EraseSection(Grid.Owner.ClassName + '$' + Grid.Name);
        finally
          Ini.Free;
        end;
      end;
    end;


    procedure RestoreGridLayOut(AGrid:TDBGridEh);
    var
      RestoreParams:TDBGridEhRestoreParams;
    begin
      RestoreParams:=[grpColIndexEh,grpColWidthsEh,grpSortMarkerEh,
        grpColVisibleEh,grpRowHeightEh];
      with AGrid do
        RestoreGridLayoutIni(ExtractFilePath(Application.ExeName) + '\Grid.ini',
          Owner.ClassName + '$' + Name,RestoreParams);
    end;     

    用了以下的办法解决了!!     跟贴就给分!!!  
       
        //保存列宽  
        DBGridEh1.SaveGridLayoutIni(ExtractFilePath(Application.ExeName)  
          +'ini\'+DBGridEh1.Owner.ClassName+'.ini',  
          DBGridEh1.Owner.ClassName+'$'+DBGridEh1.Name,true);  
        showmessage('列状态保存成功!');  
        end  
        except  
          showmessage('列状态保存失败!');  
        end;

  • 相关阅读:
    配合网页滚屏播放,做解说词
    @enable跟@import注解
    组合注解与元注解
    Spring Aware
    https的设计原理
    用信鸽来解释 HTTPS
    http三次握手四次挥手
    一致性哈希
    redis cluster原理
    redis cluster集群搭建
  • 原文地址:https://www.cnblogs.com/mingdep/p/2345307.html
Copyright © 2011-2022 走看看