Alex,

If you did something like: Grid.Row := Grid.RowCount , this will fail
because the rows range from 0 to (RowCount - 1). I would expect that
Grid.InsertColRow(false,Grid.RowCount) would also fail. The same applies
to Grid.Cells[col,row]. For example, to add a new row after the last,
you could use code like this ...

  var wRow: integer;
begin
    wRow := SGItems.RowCount;
    SGItems.RowCount := SGItems.RowCount + 1;
    SGItems.Cells[1, wRow] := CBProdCode.Text;
    SGItems.Row := wRow; // highlights the new row
end;

Dave.

On Wed, 2006-06-21 at 17:51 +0200, Alex du Plessis wrote:
> With the first instance I did.  In the second instance (InsertColRow()) 
> the grid tries to focus the cell automatically and also causes an acces 
> violation.
> 
> David B Copeland wrote:
> > On Wed, 2006-06-21 at 17:17 +0200, Alex du Plessis wrote:
> >> Hi
> >>
> >> I need to insert a new row into a StringGrid.  (TStringGrid),
> >>
> >> The grid will gladly create the new row (using a construct of 
> >> Grid.RowCount := Grid.RowCount + 1 or using Grid.InsertColRow(false,1)). 
> > 
> >>   However, an access violation occurs immediately when trying to focus a 
> >> cell within the new row.
> > 
> > How are you trying to do this? Are you using Grid.RowCount to refer to
> > it?
> > 
> >> What am I doing wrong?
> >>
> >> Alex
> > 
> > Dave.
> > 
> > 
> > 
> > 
> 
> _________________________________________________________________
>      To unsubscribe: mail [EMAIL PROTECTED] with
>                 "unsubscribe" as the Subject
>    archives at http://www.lazarus.freepascal.org/mailarchives



_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to