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;

  • 相关阅读:
    编辑器1.0
    react native定报预披项目知识点总结
    placeholder中文字添加换行方法
    ios端position为fixed失效的解决办法
    利用fis3构建前端项目工程
    webpack学习记录
    webpack学习记录-认识loader(二)
    webpack学习记录-初步体验(一)
    去抖(节流)
    css布局:左边定宽、右边自适应
  • 原文地址:https://www.cnblogs.com/mingdep/p/2345307.html
Copyright © 2011-2022 走看看