Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TStringGrid Editing

335 views
Skip to first unread message

Mitch Godfrey

unread,
Feb 4, 1999, 3:00:00 AM2/4/99
to
Question: How to make the StringGrid TRUELY always be in edit mode?

Setting the goAlwaysShowEditor option does put the grid in edit mode as
long as there is no data in the focused cell. But if there is data, it
becomes selected forcing the user to press F2 or Enter to edit the data.
I would really like to be able to force it into edit mode when a new
cell is selected.
I tried using:
StringGrid1.EditorMode := True;
which doesn't do the trick

Thanks for anyhelp,
Mitch Godfrey
Day 1 Software


Wayne Niddery (TeamB)

unread,
Feb 4, 1999, 3:00:00 AM2/4/99
to
Mitch Godfrey wrote in message <36BA3CF5...@konnections.com>...

>Question: How to make the StringGrid TRUELY always be in edit mode?
>
>Setting the goAlwaysShowEditor option does put the grid in edit mode as
>long as there is no data in the focused cell. But if there is data, it
>becomes selected forcing the user to press F2 or Enter to edit the data.
>I would really like to be able to force it into edit mode when a new
>cell is selected.


To do this, you need to get at the protected InplaceEditor property. This
can be done by creating a "cracker" descendant (descendant classes are
allowed to access protected properties and methods):

type
TCrackerGrid = class(TStringGrid);

In your grid's OnSelectCell method, just post a Windows message to the
InplaceEditor to turn off the selection:

procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
begin
PostMessage(TCrackerGrid(StringGrid1).InplaceEditor.Handle, em_SetSel, -1,
0);
end;

--
Wayne Niddery - WinWright Consulting
Delphi, C++Builder, JBuilder, InterDev --
http://home.ican.net/~wniddery/RADBooks.html
...remove chaff when replying...
"You know you've landed gear-up when it takes full power to taxi"

Mitch Godfrey

unread,
Feb 5, 1999, 3:00:00 AM2/5/99
to
Thanks Wayne,

That looks fun, I'll give it a whirl.

0 new messages