Subject | TIB_Grid - SetGridLinksWidth and GetGridLinksWidth |
---|---|
Author | rudi_josic |
Post date | 2003-07-10T21:14:08Z |
Hi,
I am trying to save the appearance (Width, col position, etc) from
the Tib_grid when closing the form, and to load this appearance when
the form is open.
I used these procedures with the dbgrids and all worked well:
{********************************************************************}
{*********************** Using DBGrid *******************************}
{********************************************************************}
procedure TForm1.SaveColWidth(Const DbGrid:TDBgrid);
var
Registro :TRegistry;
F :Byte;
begin
Registro:=TRegistry.Create;
Registro.OpenKey( '\Software\'+ExtractFileName(Application.Exename)
+'\Grids',TRUE);
for F:=0 to DbGrid.Columns.Count-1 do
Registro.WriteInteger(DbGrid.Name+'['+IntToStr(F)
+']',DbGrid.Columns[F].Width);
Registro.Free;
end;
{********************************************************************}
procedure TForm1.LoadColWidth(Var DbGrid:TDBgrid);
var
Registro :TRegistry;
F :Byte;
begin
Registro:=TRegistry.Create;
Registro.OpenKey( '\Software\'+ExtractFileName(Application.Exename)
+'\Grids',FALSE);
if Registro.ValueExists(DbGrid.Name+'[0]') then
for F:=0 to DbGrid.Columns.Count-1 do
DbGrid.Columns[F].Width:=Registro.ReadInteger
(DbGrid.Name+'['+IntToStr(F)+']');
Registro.Free;
end;
{********************************************************************}
I try to apply it to the ibo with:
{********************************************************************}
{********************** Using Tib_Grid ******************************}
{********************************************************************}
procedure LoadColWidth(Var Grid:Tib_Grid);
var
Registro :TRegistry;
F :Byte;
begin
Registro:=TRegistry.Create;
Registro.OpenKey('\Software\CBS\Grids',False);
if Registro.ValueExists(Grid.Name+'[0]') then
for F:=0 to grid.DataSource.Dataset.FieldsVisible.Count-1 do
Grid.SetGridLinksWidth(F,inttostr(Registro.ReadInteger
(Grid.Name+'['+IntToStr(F)+']')));
Registro.Free;
end;
{********************************************************************}
procedure SaveColWidth(Const Grid:Tib_Grid);
var
Registro :TRegistry;
F :Byte;
begin
Registro:=TRegistry.Create;
Registro.OpenKey('\Software\CBS\Grids',True);
for F:=0 to grid.DataSource.Dataset.FieldsVisible.Count-1 do
Registro.WriteInteger(Grid.Name+'['+IntToStr(F)+']',strtoint
(grid.GetGridLinksWidth(F)));
Registro.Free;
end;
{********************************************************************}
but when I test the procedure, it raise an error:
EListError: List index out of bounds(0).
I think that it is when try to read GetGridLinksWidth, I don't know,
am I making well in using this function? or is there another function
to get the visible columns of the grid?
if somebody knows another way to do this and can help me, i would
thank a lot
Thanks in advance.
Rudi Josic.-
I am trying to save the appearance (Width, col position, etc) from
the Tib_grid when closing the form, and to load this appearance when
the form is open.
I used these procedures with the dbgrids and all worked well:
{********************************************************************}
{*********************** Using DBGrid *******************************}
{********************************************************************}
procedure TForm1.SaveColWidth(Const DbGrid:TDBgrid);
var
Registro :TRegistry;
F :Byte;
begin
Registro:=TRegistry.Create;
Registro.OpenKey( '\Software\'+ExtractFileName(Application.Exename)
+'\Grids',TRUE);
for F:=0 to DbGrid.Columns.Count-1 do
Registro.WriteInteger(DbGrid.Name+'['+IntToStr(F)
+']',DbGrid.Columns[F].Width);
Registro.Free;
end;
{********************************************************************}
procedure TForm1.LoadColWidth(Var DbGrid:TDBgrid);
var
Registro :TRegistry;
F :Byte;
begin
Registro:=TRegistry.Create;
Registro.OpenKey( '\Software\'+ExtractFileName(Application.Exename)
+'\Grids',FALSE);
if Registro.ValueExists(DbGrid.Name+'[0]') then
for F:=0 to DbGrid.Columns.Count-1 do
DbGrid.Columns[F].Width:=Registro.ReadInteger
(DbGrid.Name+'['+IntToStr(F)+']');
Registro.Free;
end;
{********************************************************************}
I try to apply it to the ibo with:
{********************************************************************}
{********************** Using Tib_Grid ******************************}
{********************************************************************}
procedure LoadColWidth(Var Grid:Tib_Grid);
var
Registro :TRegistry;
F :Byte;
begin
Registro:=TRegistry.Create;
Registro.OpenKey('\Software\CBS\Grids',False);
if Registro.ValueExists(Grid.Name+'[0]') then
for F:=0 to grid.DataSource.Dataset.FieldsVisible.Count-1 do
Grid.SetGridLinksWidth(F,inttostr(Registro.ReadInteger
(Grid.Name+'['+IntToStr(F)+']')));
Registro.Free;
end;
{********************************************************************}
procedure SaveColWidth(Const Grid:Tib_Grid);
var
Registro :TRegistry;
F :Byte;
begin
Registro:=TRegistry.Create;
Registro.OpenKey('\Software\CBS\Grids',True);
for F:=0 to grid.DataSource.Dataset.FieldsVisible.Count-1 do
Registro.WriteInteger(Grid.Name+'['+IntToStr(F)+']',strtoint
(grid.GetGridLinksWidth(F)));
Registro.Free;
end;
{********************************************************************}
but when I test the procedure, it raise an error:
EListError: List index out of bounds(0).
I think that it is when try to read GetGridLinksWidth, I don't know,
am I making well in using this function? or is there another function
to get the visible columns of the grid?
if somebody knows another way to do this and can help me, i would
thank a lot
Thanks in advance.
Rudi Josic.-