Board index » delphi » TStringList - Adding Rows at Runtime

TStringList - Adding Rows at Runtime

Question,

I finally have an application where users can enter more data than they
started with.  But, I now am looking at user interface questions.  One
question that has come up is this:

How, using the keyboard, can a user add more rows to an existing String
Grid?

I know I can add more rows through a button, but they would like to add them
automatically, as needed.  This would be similar to the way Word adds more
rows to a table, by pressing the tab key in the last cell.

The only way I know to do this is to add code to the OnKeyDown event for the
grid.  The code looks like:

IF (char(KEY) = #9) or (key = VK_DOWN)  THEN
  with StringGrid1 do
    if (row = RowCount-1) and (Col = ColCount -1) then
        RowCount := RowCount + 1;

While this works, I would like to know if there is a better way to do this,
otherwise I can see adding this code to every string grid I use.

As a side question, what about inserting a row in the middle, or deleting an
existing row.  Are there any keyboard commands?  Or, are there standard
keystrokes that are not implemented?  (That may be implmented similar to the
above code).

Thanks in advance.

Doug Farmer
d...@roisysinc.com

 

Re:TStringList - Adding Rows at Runtime


Doug -

Unlike a TDBGrin, there's no provisions for keyboard handling to add
or insert rows on a TStringGrid. If you need to do this for multiple
components, you can add your code to a descendant of TStringGrid, and
use that component instead.

Good luck.

Kurt

Re:TStringList - Adding Rows at Runtime


On Tue, 17 Feb 1998 02:22:47 GMT, 71333.2...@compuserve.com (Kurt

Quote
Barthelmess (TeamB)) wrote:
> Unlike a TDBGrin

Is that where you get these -- <g> -- from a database?

--
Rick Rogers (TeamB) | Fenestra Technologies

Re:TStringList - Adding Rows at Runtime


Kurt,

Thanks for the reply.  BTW, what are the keyboard shortcuts for the DBGRID.
I'm not sure I even know those.  Also, if I am not being nosy, I see lots of
people with the Team B designation.  What does that mean?  Just Curious

Doug

Kurt Barthelmess (TeamB) <71333.2...@compuserve.com> wrote in message
<34e8f0a2.3769...@forums.borland.com>...

Quote
>Doug -

>Unlike a TDBGrin, there's no provisions for keyboard handling to add
>or insert rows on a TStringGrid. If you need to do this for multiple
>components, you can add your code to a descendant of TStringGrid, and
>use that component instead.

>Good luck.

>Kurt

Re:TStringList - Adding Rows at Runtime


Doug -

 > Thanks for the reply.  BTW, what are the keyboard shortcuts for the DBGRID.
 > I'm not sure I even know those.

Other than the standard Windows shortcuts for Cut, Copy, Paste, and
Delete, none. And those only work when a field is editable, and apply
only when editing a field - not to a row.

 > Also, if I am not being nosy, I see lots of
 > people with the Team B designation.  What does that mean?  Just Curious

TeamB is a group of volunteers who try to help with technical
questions here on the newsgroups. None of us work for Borland. Anyone
wearing a "TeamB hat" here means that you have some assurance that the
writer has some expertise in the matter being discussed. Not
guaranteed, but your odds are better than in the lottery. Oh, and we
also walk on water<G>.

Good luck.

Kurt

Re:TStringList - Adding Rows at Runtime


Rick -

 > > Unlike a TDBGrin
 > Is that where you get these -- <g> -- from a database?

Like other portions of my anatomy, my fingers are fat.<G>

Good luck.

Kurt

Other Threads