[DUG] StringGrid
John Bird
johnkbird at paradise.net.nz
Tue Sep 13 16:16:19 NZST 2005
I am looking to extend standard stringgrid for data entry, been checking out
behind the scenes and if I intercept certain events I think so far I can set
it up to do what I want.....
Questions:
Q1 - I have code such as below to intercept the Enter key and convert to TAB
to move from component to component, works fine except for stringgrid as
Enter seems to be captured internally to turn on the inline editor for a
cell. Is there a way anyone knows to alter the editor for cell data so that
Enter could be altered to move from cell to cell as many operators would be
used to. I still want to use the inline editor to edit text in the cell,
maybe only use F2 to toggle it instead of F2 or Enter
Q2 - Is there any easier way to find out where on the screen the current
cell is (eg I can do this by interrogating in the onDrawCell event, using
the rect parameter and translating into absolute screen points). It would
be simpler to use the onSelectCell event as it fires once when the focus
arrives at that cell, whereas onCellDraw is firing all the time for other
things (such as the grid being obscured etc).
Forward declaration:
procedure CMDialogKey(Var Msg: TWMKEY); message CM_DIALOGKEY;
procedure:
procedure TfrmCoinqSrch.CMDialogKey(var Msg: TWMKEY);
{
This converts ENTER key messages to TAB key messages, provided a few
conditions hold
}
begin
if (ActiveControl is TCustomEdit)
or (ActiveControl is TRadioButton)
or (ActiveControl is TStringGrid)
then
begin
if Msg.CharCode = VK_RETURN then
begin
Msg.CharCode := VK_TAB;
KeyDir:='Next';
end;
if Msg.Charcode = VK_ESCAPE then
begin
Msg.CharCode := VK_TAB;
KeyDir:='Prev';
end;
end;
inherited;
end;
//when arrow to new cell event order is
//onKeyDown
//On KeyUp
//onSelectCell (newcell)
//onDrawCell (old)
//onDrawCell (new)
//click on cell
//on click
//onSelectCell new
//onDrawCell old
//onDrawcell new
//onclick
John B
More information about the Delphi
mailing list