Subject | Re: [IBO] TIB_GRID, OnGetCellProps and BufferFields |
---|---|
Author | russellbelding |
Post date | 2004-05-25T10:03:41Z |
Hello Helen
Thanks for your reply.
In the onGetCellProps event handler I am not interested in the widths
of columns, I should have made that clear. I use the column widths
only in the form create procedure and the form close procedure,
allowing a users prior grid settings to have effect.
Each row in the grid represents an event which may be active or
inactive. In a particular call by the TIB_Grid class to the event
handler I am interested in a setting "is the current row an active
event?", and I set the font and background colors by user preference.
In a particular call to the event handler for a particular row and
column, the values
myQuery.FieldByName(myBooleanField)asBoolean and
myQuery.BufferFields.Columns[MyFieldIndex].AsBoolean
are usually not the values for the row for which the event handler is
called. Painting colors using these values paint all rows the same.
Only when I use
myQuery.BufferFieldsByName(myBooleanField).AsBoolean
do I get good results, and then the first (FixedDataCols+1) values
are the values for the previous row, which is my problem.
I have started looking in the TIB_GRID, TIB_COMPONENTS.PAS and
Borland code but am swamped by unfamiliar details at present.
Regards
Russell
Thanks for your reply.
In the onGetCellProps event handler I am not interested in the widths
of columns, I should have made that clear. I use the column widths
only in the form create procedure and the form close procedure,
allowing a users prior grid settings to have effect.
Each row in the grid represents an event which may be active or
inactive. In a particular call by the TIB_Grid class to the event
handler I am interested in a setting "is the current row an active
event?", and I set the font and background colors by user preference.
In a particular call to the event handler for a particular row and
column, the values
myQuery.FieldByName(myBooleanField)asBoolean and
myQuery.BufferFields.Columns[MyFieldIndex].AsBoolean
are usually not the values for the row for which the event handler is
called. Painting colors using these values paint all rows the same.
Only when I use
myQuery.BufferFieldsByName(myBooleanField).AsBoolean
do I get good results, and then the first (FixedDataCols+1) values
are the values for the previous row, which is my problem.
I have started looking in the TIB_GRID, TIB_COMPONENTS.PAS and
Borland code but am swamped by unfamiliar details at present.
Regards
Russell
--- In IBObjects@yahoogroups.com, Helen Borrie <helebor@t...> wrote:
> At 04:15 AM 25/05/2004 +0000, you wrote:
> >Using IBO4.3Aa, D6, FB 1.5.
> >
> >In TIB_GRID the onGetCellProps event handler allows me to set the
> >background color and the font color for each column in the grid. I
am
> >using this event handler to set these colors depending on field
data
> >in the current row. The grid data comes from a TIB_Query, myQuery.
> >The event handler is called with column and row numbers ACol and
ARow
> >where ARow is the row number of a visible row. To examine the data
in
> >the row when the event handler is called I must use
> >myQuery.BufferFieldsByName(myFieldName).asWhatever (*)
> >to examine the data field of the current row. The grid has
> >FixedDataCols fixed data columns set in the published grid
properties.
> >The data returned by (*) in the event handler is for the current
row
> >for those columns numbered by Acol (FixedDataCols+2) and greater
but
> >contains the data for the previous row for columns 1,2,...
> >(FixedDataCols+1). This is the source of my problem.
> >
> >I have made the following changes to IB_GRID.PAS
> >
> >{ Methods }
> >{start changes by russell}
> > function PublicColWidths(I:integer):integer;
> > procedure PublicColWidthsChanged;
> >{end changes by russell}
> >
> >{start changes by russell}
> >function TIB_CustomGrid.PublicColWidths(I:integer): integer;
> >begin
> > Result := colWidths[I];
> >end;
> >
> >procedure TIB_CustomGrid.PublicColWidthsChanged;
> >begin
> > ColWidthsChanged;
> >end;
> >{end changes by russell}
> >
> >I would have backed out these changes and then tested but the
changes
> >required to my code after backing out theses changes to IB_GRID.PAS
> >are many, and I am guessing these changes have not upset the code
in
> >IB_GRID.PAS.
> >
> >So I am submitting my problem here in the hope of saving time.
> >
> >Is the behaviour of BufferFieldsByName(..) descibed above intended?
> >If not how can it be changed? If correct how can I get the correct
> >data for low numbered columns in the event handler?
>
> Why not just refer to the Columns property of the ib_row? (In this
case,
> BufferFields or Fields...since you are handling the current row,
they are
> the same). Columns is an array of TIB_Column, so, as long as your
> FixedCols stay fixed, you can read from/write to the DisplayWidth
property
> of the data column. When you write to DisplayWidth, the grid will
react
> accordingly.
>
> Helen