How to store and read DBGrid layout to/from INI file ---------------------------------------------------- Use the following routines in the form's OnCreate and OnDestroy events respectively : procedure tForm1.ReadGridsLayout(IniF: tIniFile); Var I,J : integer; Coll: tList; tabS: String; begin For I := 1 to ComponentCount do if Components[I-1] Is tDBGrid then With Components[I-1] as tDBGrid do begin if (dataSource <> NIL) and (DataSource.dataSet <> NIL) then tabs := DataSource.dataSet.name else tabS := ''; if assigned(Columns) then with Columns do begin Coll := tList.Create; Try { read columns width and position } For j := 0 to Count-1 do Coll.Add(NIL); For j := 0 to Count-1 do With Items[j] do begin Width := IniF.ReadInteger(Self.Caption,tabS+'_'+Fieldname+'_Width',Width); Coll.Items[IniF.ReadInteger(Self.Caption,tabS+'_'+Fieldname+'_Index',J)] := Items[j]; end; For j := 0 to Coll.Count-1 do if Coll.Items[j] <> NIL then tColumn(Coll.Items[j]).Index := j; Finally Coll.Free; end; end end; end; procedure tForm1.StoreGridsLayout(IniF: tIniFile); Var I,J : Integer; tabS: String; begin For I := 1 to ComponentCount do if Components[I-1] Is tDBGrid then With Components[I-1] as tDBGrid do begin if (dataSource <> NIL) and (DataSource.dataSet <> NIL) then tabS := DataSource.dataSet.name else tabS := ''; if assigned(Columns) then with Columns do For j := 0 to Count-1 do With Items[j] do begin IniF.WriteInteger(Self.Caption,tabS+'_'+Fieldname+'_Width',Width); IniF.WriteInteger(Self.Caption,tabS+'_'+Fieldname+'_Index',J); end; end; end;