Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread Problem with grid and Database.AutoTransaction
Fri, Oct 7 2016 2:48 PMPermanent Link

thomh

Hi,

Inorder to avoid the "Database commit response error" I put this in the forms OnCreate event:

Database.AutoTransactions := False;

However, this causes the grid to not respond to keyboard scrolling (up/down keys).
I can select with the mouse.

// Thom
Fri, Oct 7 2016 4:59 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Thom,

<< Inorder to avoid the "Database commit response error" I put this in the forms OnCreate event:

Database.AutoTransactions := False;

However, this causes the grid to not respond to keyboard scrolling (up/down keys). I can select with the mouse. >>

Are you modifying any columns in the row before trying to move away ?

Tim Young
Elevate Software
www.elevatesoft.com
Fri, Oct 7 2016 5:00 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Thom,

My first guess would be that you've got a TDataSet.BeforeSave event handler that isn't returning True.

Tim Young
Elevate Software
www.elevatesoft.com
Sat, Oct 8 2016 5:36 AMPermanent Link

thomh

Tim,

Here's the code. The problem seems to be placing the loading
of the dataset in the FormShow event. Note that Form2 is created
in panel on Form1.

procedure TForm2.DataSetCreate(Sender: TObject);
begin
 Database.AutoTransactions := False;
end;

// ******** Placing the code here does not allow me use the up/down keys
procedure TForm2.Form2Show(Sender: TObject);
begin
 DataSet.Open;
 DataSet.Insert;
 DataSet.Columns['Description'].AsString := 'Doc 1';
 DataSet.Save;
 DataSet.Insert;
 DataSet.Columns['Description'].AsString := 'Doc 2';
 DataSet.Save;
 DataSet.First;
 Grid1.SetFocus;
end;

// ******* Placing the code in a button click event works fine
procedure TForm2.Button1Click(Sender: TObject);
begin
 DataSet.Open;
 DataSet.Insert;
 DataSet.Columns['Description'].AsString := 'Doc 1';
 DataSet.Save;
 DataSet.Insert;
 DataSet.Columns['Description'].AsString := 'Doc 2';
 DataSet.Save;
 DataSet.First;
 Grid1.SetFocus;
end;

// ****** Changing the FormShow event to this works as well
procedure TForm2.Form2Show(Sender: TObject);
begin
 async Button1Click(nil);
end;

// Thom
Sun, Oct 9 2016 1:33 PMPermanent Link

Raul

Team Elevate Team Elevate

On 10/8/2016 5:36 AM, thomh wrote:
> Here's the code. The problem seems to be placing the loading
> of the dataset in the FormShow event. Note that Form2 is created
> in panel on Form1.

I suspect it's simply that the grid does not get focus for keyboard
events to work.

If you click on grid once with the mouse do the arrows then work ?

> // ******** Placing the code here does not allow me use the up/down keys
> procedure TForm2.Form2Show(Sender: TObject);
> begin
>   DataSet.Open;
>   DataSet.Insert;
>   DataSet.Columns['Description'].AsString := 'Doc 1';
>   DataSet.Save;
>   DataSet.Insert;
>   DataSet.Columns['Description'].AsString := 'Doc 2';
>   DataSet.Save;
>   DataSet.First;
>   Grid1.SetFocus;
> end;

Have you tried changing just the Grid1.SetFocus to be async ?

Raul
Sun, Oct 9 2016 2:47 PMPermanent Link

thomh

Raul,

async Grid1.SetFocus works.

>>If you click on grid once with the mouse do the arrows then work ?

No, they do not.

// Thom
Tue, Oct 11 2016 1:31 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Thom,

<< No, they do not. >>

You're probably seeing the grid focus bug that was introduced in 2.05.  I'm doing a new 2.05 B5 soon, and that will have a fix for this issue.

Tim Young
Elevate Software
www.elevatesoft.com
Image