Sorry Dave,

That's not it yet.

Here is my code:

StringGrid1.InsertColRow(false,1);//Notice it is creating a new line at the top of the grid
StringGrid1.Col := 1;
StringGrid1.Row := 2;

And this works fine. The line is created at the top and the focus moved to the second row. no problems there.

However, when you move to any cell in the newly created row (either by clicking or keyboard) the access violation occurs?

Any thoughts?

Alex

David B Copeland wrote:
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



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

Reply via email to