Jump to content

Recommended Posts

Posted

Hi,

I would like to store the visible columns in each grid and the width of each visible column so when the user enters the same form again he gets the same view again.

It is my purpose to store this to a database so the user gets the same lay-out on any machine he uses.

Thx,

Bernaert Dominique

Posted

I have wrote such a class. But it has the dependence of the JVCL library. I don't know, is it good idea to piblish it. It can save and restore Width, Index, Visible and Expanded properties of each column in a TUniDBGrid. On the server side, store by user, in registry, db, xml or ini file.

Posted

Hi,

would it be possible to send it over? I would like to take a look at it if you would be willing to share this? If you don't want to post it public, please send me a private message. Would be greatly appreciated.

Thx,

Dominique

Posted

Okay, here's this module.

Usage, forms, pas:

procedure TUniForm14.UniFormClose(Sender: TObject; var Action: TCloseAction);
begin
 JvFormStorage1.StoredValues.Values['Form14Width'].Value  := Width;
 JvFormStorage1.StoredValues.Values['Form14Height'].Value := Height;
 SaveGridLayout;
 JvFormStorage1.SaveFormPlacement;
end;

procedure TUniForm14.UniFormCreate(Sender: TObject);
begin
 JvFormStorage1.AppStorage := UniMainModule.AppRegistryStorage;
 JvFormStorage1.RestoreFormPlacement;
 Width  := JvFormStorage1.StoredValues.Values['Form14Width'].Value;
 Height := JvFormStorage1.StoredValues.Values['Form14Height'].Value;
 LoadGridLayout;
end;

procedure TUniForm14.SaveGridLayout;
var
 SaveLayout: TUniGridLayOut;
begin
 SaveLayout := TUniGridLayOut.Create(nil);
 try
  SaveLayout.SaveLayout(JvFormStorage1, UniDBGrid1, 'Form14Grid1');
  SaveLayout.SaveLayout(JvFormStorage1, UniDBGrid2, 'Form14Grid2');
 finally
  FreeAndNil(SaveLayout);
 end;
end;

procedure TUniForm14.LoadGridLayout;
var
 LoadLayout: TUniGridLayOut;
begin
 LoadLayout := TUniGridLayOut.Create(nil);
 try
  LoadLayout.LoadLayout(JvFormStorage1, UniDBGrid1, 'Form14Grid1');
  LoadLayout.LoadLayout(JvFormStorage1, UniDBGrid2, 'Form14Grid2');
 finally
  FreeAndNil(LoadLayout);
 end;
end;

DFM:

  object JvFormStorage1: TJvFormStorage
    Active = False
    AppStoragePath = 'Form14Placement\'
    Options = []
    StoredValues = <
      item
        Name = 'Form14Width'
        Value = 943
      end
      item
        Name = 'Form14Height'
        Value = 688
      end>
    Left = 559
    Top = 164
  end

Usage, the MainModule, pas:

procedure TUniMainModule.UniGUIMainModuleBeforeLogin(Sender: TObject; var Handled: boolean);
begin
 if Handled then
 begin
  .....
  AppRegistryStorage.Root := AppRegistryStorage.Root + '\' + UniMainModule.LoggedUserUID;
 end;
end;

DFM:

  object AppRegistryStorage: TJvAppRegistryStorage
    StorageOptions.BooleanStringTrueValues = 'TRUE, YES, Y'
    StorageOptions.BooleanStringFalseValues = 'FALSE, NO, N'
    Root = 'Software\ACME Software\UniGuiStorage'
    SubStorages = <>
    Left = 504
    Top = 216
  end

 

SaveUniGrid.pas

  • 5 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...