Subject Re: [IBO] TIB_Grid Col displaywidth
Author Russell Belding
Thanks Geoff for the pointer.

My task is to save the configuration of a Delphi form per user and restore
it when the user next creates that form. This includes form position and
size, and for each TIB_Grid in the form, the position and width of each grid
column. To read the width of each grid column I had used the TIB_Grid's
TCustomGrid.colwidth array because TIB_Grid.GridField[I].DisplayWidth does
not update when the column is resized by mouse action. To read these values
required a new function in IB_GRID.PAS (so the new function must be remade
for each version of IBO)

Am I right in thinking myGrid.GridFields[I] is a TIB_Column of the dataset
of myGrid.dataSource? So changing its properties changes all grids using the
dataset? This is not clear in the IBO help file.

To set the order and width of the columns in a grid I use
myGrid.GridLinks.Clear,
and for each column in the grid
myGrid.GridLinks.Append(SavedColName)
myGrid.GridFields[IOrder].displayWidth := SavedColWidth
If myGrid.GridFields are the fields of myGrid.dataSource.dataSet then the
above line is wrong as it changes all grids using the same dataset. If so I
should be using
myGrid.GridLinks.Append(SavedColName+'=WIDTH='+inttostr(SavedColWidth))
which works and changes only myGrid.

My only problem now is reading the grid column widths.

You indicated TIB_Grid.GridLinks may contain updated column widths.

The behaviour of TIB_Grid GridLinks, a TStringlist, seems to be as follows:
To get the width of column MyCol first look for an entry in GridLinks of the
form
MYCOL=WIDTH=NN
If present the current width is NN. If not present the width is
myGrid.GridFields[I_forMyCol].displaywidth.

If an entry "MYCOL=WIDTH=NN" is present in GridLinks and then
myGrid.GridFields[I_forMyCol].displaywidth := NN is set the entry in
GridLinks reverts to "MYCOL".

Reading the current colWidths by looking in two places seems to me to be too
messy.

So I suggest a change to TIB_Grid that makes visible read only values of the
base TCustomForm.ColWidth(I). At present (ver4.2Ib), I think, these values
are not visible in TIB_Grid. Then the current column widths of any TIB_Grid
can be read in a simple manner.

Best regards

Russell Belding







----- Original Message -----
From: "Geoff Worboys" <geoff@...>
To: "Russell Belding" <IBObjects@yahoogroups.com>
Sent: Friday, January 17, 2003 2:24 AM
Subject: Re: [IBO] TIB_Grid Col displaywidth


> > When columns in a TIB_Grid have their widths changed by a mouse
> > drag the TIB_Grid values GridFields[I].DisplayWidth are not
> > changed.
>
> > This seems to be an error.
>
> No this is not an error, GridFields surfaces the underlying
> TIB_Column property - so changes would impact all grids etc.
>
> Check out TIB_Grid.GridLinks. Some time ago Claudio added the
> ability to define grid specific column widths using that
> property. I am not sure if it will change with user drag of
> column widths but its worth checking.
>
>
> > When a TIB_Grid has computed columns the name of the computed
> > column is reported as an empty string in GridFields[I].SQLName
> > but is correct in GridFields[I].FieldName. Is this an error at
> > SQLName?
>
> No. Computed columns do not have an SQL name. SQLName is a
> misnomer - carried over from the API. SQLName is actually the
> name of the column in the underlying entity, and computed fields
> dont have such a column (unless the computed value is defined as
> part of the entity itself).
>
>
> --
> Geoff Worboys
> Telesis Computing
>
>
>
>
___________________________________________________________________________
> IB Objects - direct, complete, custom connectivity to Firebird or
InterBase
> without the need for BDE, ODBC or any other layer.
>
___________________________________________________________________________
> http://www.ibobjects.com - your IBO community resource for Tech Info
papers,
> keyword-searchable FAQ, community code contributions and more !
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>