[DUG] StringGrid

Rohit Gupta rohit at cfl.co.nz
Tue Sep 13 16:53:11 NZST 2005


I gave up on Stringgrid very early on.  I use the DBgrid.  If its for 
non-data aware stuff then I use a clientdataset with it.

The Field parameter tells you which col its on  and interrogating the 
cds tells you which row its on.

From:           	"John Bird" <johnkbird at paradise.net.nz>
To:             	"'NZ Borland Developers Group - Delphi List'" <delphi at ns3.123.co.nz>
Subject:        	[DUG] StringGrid
Date sent:      	Tue, 13 Sep 2005 16:16:19 +1200
Organization:   	John Bird Consulting
Send reply to:  	johnkbird at paradise.net.nz,
       	NZ Borland Developers Group - Delphi List <delphi at ns3.123.co.nz>
	<mailto:delphi-request at ns3.123.co.nz?subject=unsubscribe>
	<mailto:delphi-request at ns3.123.co.nz?subject=subscribe>

[ Double-click this line for list subscription options ] 

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


_______________________________________________
Delphi mailing list
Delphi at ns3.123.co.nz
http://ns3.123.co.nz/mailman/listinfo/delphi
Regards

Rohit

======================================================================
CFL - Computer Fanatics Ltd.  21 Barry's Point Road, AKL, New Zealand
PH    (649) 489-2280 
FX    (649) 489-2290
email rohit at cfl.co.nz  or  r.gupta at xtra.co.nz
======================================================================




More information about the Delphi mailing list