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;

  • 相关阅读:
    图解机器学习读书笔记-CH3
    塑造职场影响力的五大法宝
    怎样培养独挡一面的能力
    数据结构
    [分享]恼人的设计模式
    Git使用总结
    设计师整理的系统开发流程-简洁又有重点
    JavaScript中的String对象
    python高效解析日志入库
    如何让js不产生冲突,避免全局变量的泛滥,合理运用命名空间
  • 原文地址:https://www.cnblogs.com/mingdep/p/2345307.html
Copyright © 2011-2022 走看看