Subject Re: [IBO] TIB_Grid Col displaywidth
Author Geoff Worboys
> To read these values required a new function in IB_GRID.PAS (so
> the new function must be remade for each version of IBO)

All significant applications should make the practice of deriving
their own versions of commonly used components. Just create your
own package and add very simple derivations of desired classes
and install and use in your application. This practice means
that you are prepared for situations such as this and can readily
make such simple changes without requiring changes to the external
library source code.

> 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?

That is correct.

> 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.

That is sort of correct. You may find it useful in some situations
to use the public functions SetGridLinksWidths (and for reading the
corresponding GetGridLinksWidths). Beware of these methods, they
only get/set if there is a column entry in the GridLinks. Note also
that those methods return/accept the number as a string value, and
that string may be blank if no width has been explicitly defined.

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

One way or another it will be necessary. The GridLinks widths
are only available if they have been defined, so you either have
to be certain they have been defined (initialise from DisplayWidth)
or be prepared to read the base/column value when no specific
width has been given.

AFAICT; If you force the gridlinks widths to be defined (init
on form creation, and provide a default of the DisplayWidth
if no saved value is available), then those widths will be
kept current as the user alters the column widths. And this
means that, on save, you can rely on GetGridLinksWidths only.

> 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.

Thats up to Jason. My suggestion about creating your own
derivation is the way to work around this for the moment.


Geoff Worboys
Telesis Computing