[DUG] Grids for data entry
John Bird
johnkbird at paradise.net.nz
Tue Nov 28 17:56:50 NZDT 2006
Question in brief:
For a standard StringGrid or DBGrid (ClientDataSet) Is there an easy way to
get events for:
(1) detecting when I have moved from one cell to another ie an onCellExit
event
(2) detecting when the contents of a cell have been altered while in there
ie an onCellChange event or a property CellChanged which could be set if the
cell is edited since arriving in it (checked at the onCellExit event).
Or is it better to go to a commercial grid. Which grids out there would you
recommend?
Have looked a but at many such as Woll2Woll VirtualTreeView and others but
without actually buying them and buckling down and learning them it is hard
to know how easy/flexible/robust they really are.
More detailed explanation:
Up to now I have done a lot with the standard VCL StringGrid.
The advantages are that I get it to behave pretty much as I want:
-Mainly I pop-up a second grid when a cell changes with matching options to
choose from - and I coded it myself as I am not making a combo list, I have
at least 2 columns with either a numerical code and a description either of
which can be used for looking up valid values. That part I have working
well - involves a few subtle issues about placing the second grid as a new
modal window at the location of the current cell.
- No upgrade issues going to a later version of delphi.
but the main limitations is that it lacks events for
(1) detecting when I have moved from one cell to another ie an onCellExit
event
(2) detecting when the contents of a cell have been altered while in there
ie an onCellChange event or a property CellChanged which could be set if the
cell is edited since arriving in it.
If I have these extra events, I could do an awful lot more for smart editing
of data. At present I do an lot of fiddly code in various events to detect
the moving from one cell to another.
This involves quite a bit of extra code to be used, for example:
Set of routines to give behind scenes setup of std Stringgrid for input with
lookup
call xcSGridInit once (sets a number of dynamic arrays to track cell
contents and types)
call xcSGridColDef once for each row to set field types
call xcSGridCellStart in GetEditMask event to set which is current cell
call xcSGridCellCheck in grid exit event and SelectCell event (start of
selecting new cell)
call xcSGridFinish in formclose or similar to free arrays
Note defaultdrawing for cells can be set to off (can use to highlight errors
in a cell)
also has routines to add/delete rows and print grid contents using Rave
John
More information about the Delphi
mailing list