Subject Re: [IBO] Re: SemiAuto inserting text into gridcell
Author Geoff Worboys
> But ...
> What's so special about the cell in the grid.

A cell in a grid is not an edit control - it displays the inplace
editor to manage input. In addition there is LOTS of key related
manipulation in the grid (and between the grid and the inplace
editor), this can sometimes make it very difficult to achieve things
which are very simple in your standard controls.

For example, when you hit a character key (and alwaysshoweditor is
false, so the inplace editor is not visible) it goes to the grid first
which then shows the inplace editor and tries to give it the key.
(which is probably why your keydown processing did not work). Once
the inplace editor is showing the grid expects input will go directly
to the editor (which also passes keystrokes back to the grid for
special interpretations). Since your processing was still sending
directly to the grid things get rather confused.


> Will I have to find the fieldname and use:
> ibqrKINO.FieldByName(FIELDNAME).AsString:=MACRO3[...];
> Is there a straightforward way to get the fieldname for the
> current cell in the grid?

This is one option. See DataCol, GridFields, GridRow and DataRow
properties for IB_Grid in the online help. There are examples on how
to use these in the a few of the sample apps (eg. Contact sample used
in the GetCellProps event handler).

Another option would be to drop TIB_EditEnh onto the grid, set
alwaysshoweditor to true and then you can setup your standard control
processing against the event handlers of the actual control.

Personnally I think assigning directly to the field is probably the
better option. I think this should work in keydown processing - but
you may have to put some special processing into KeyPress on the grid,
otherwise it will still get the keypress event and try to insert that
into the inplace editor, possibly overwriting what you just inserted
directly into the field.


> Why did the previous test work when run in the IDE with a
> breakpoint, and otherwise fail?

All sorts of things happen in IB_Grid as focus is gained and lost.
This can sometimes be compounded by the callbacks performed by IBO
during data retrieval. Combine this with interruption and slower code
reaction times while debugging and things can get very confused.


I hope some of this makes sense. Working with IB_Grid (or any
derivation of TCustomGrid) can be very time consuming and confusing.

Geoff Worboys
Telesis Computing