View Issue Details

IDProjectCategoryView StatusLast Update
0019993LazarusLCLpublic2012-11-22 13:46
ReporterStefano Assigned ToJesus Reyes  
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product Version0.9.30 
Target Version1.2.0Fixed in Version1.1 (SVN) 
Summary0019993: Bugs in DbGrid with Lazarus 0.9.30
DescriptionHello, I've installed Lazarus 0.9.30 and I finded problems with DbGrid. With Lazarus 0.9.28 all worked very good.

1) Grid columns with ScrollBars = ssVertical and AutoFillColumns = True have problems, when the Grid is complex with settings columns Visibile or not visible or columns width at runtime. In some cases the last columns of the grid hat width minor, the difference is = width scrollbar. With ScrollBar = ssAutoVertical is ok.

2) Non visible columns have always Width = 0. With Lazarus 0.9.28 I can set Width all columns, and when I set a columns visible = True, the columns hat already the desired Width.

3) If 1. columns is not visible the Key Home doesn't work (may be auch last column if not visible with End Key, I have not tried).

4) When I write oder modify data (edit state) in last column of the grid, the grid lost focus when I exit the edit state with Key Arrow Right or Tab. Here is my code in KeyDown event:

  if (dbgrid3.SelectedIndex = dbgrid3.Columns.Count - 1) and (Key in [KeyTab, KeyArrowRight]) then begin
    dbgrid3.SelectedIndex := 0;
    Key := 0;
    fbdataset4.Next;
    if (fbdataset4.EOF = True) then fbdataset4.Append;
    //Lazarus 0.9.30
    try
      dbgrid3.SetFocus;
    finally
    end;
  end;

Without dbgrid3.SetFocus the grid lost focus.

At end event KeyDown I added however this code with Lazarus 0.9.30, else can lost focus:

  if Key in [KeyHome, KeyEnd, KeyPgUp, KeyPgDown, KeyArrowUp, KeyArrowDown, KeyArrowLeft, KeyArrowRight] then begin
    //Calcolo dati griglia
    if (fbdataset4.State in [dsEdit, dsInsert]) then fbdataset4.Post; //Altrimenti spostandosi con freccia dx sul primo riga perde il dato della colonna 0
    if (B = False) then begin
      //Focus rimasto su griglia contabile
      try
        dbgrid3.SetFocus;
      finally
      end;
    end;
  end;

5) In some other cases I noted that the grid lost focus, while with Lazarus 0.9.28 all worked good. Now is difficult for me to reproduce these cases.

Sorry for my bad englisch.

Best regards,

Stefano Cortelli
Additional InformationDebian Squeeze - GTK 2 - Lazarus 0.9.30 stable
TagsNo tags attached.
Fixed in Revision39316, 39317
LazTarget1.2
WidgetsetGTK 2
Attached Files

Relationships

related to 0022804 assignedJesus Reyes DBGrid lost focus when moving into the dataset 
related to 0022476 resolvedJesus Reyes DbGrid with ButtonStyle = cbsCheckBox + other 

Activities

Stefano

2011-08-17 17:11

reporter   ~0050907

Hello, today I've noted also:

6) if the dbgrid hat horizontal scrollbar (ssBoth, ssAutoBoth), when I use the horizontal scroolbar (for exemple I move the horizontal scrollbar right, to show other columns on right) the grid lose focus.

Moreover, until the grid hat no focus (if I dont'k click on the dbgrid to have focus) if I scroll with the mouse or if I press Arrow Down to move in the rows of the dbgrid, the program crash.

Best regards,

Stefano

Stefano

2011-08-19 16:05

reporter   ~0050952

Hello, Today I have noted also that:

If I have 2 or more forms (with DbGrid) in a program compiled with Lazarus 0.9.30, when the focus is on the dbgrid and when I move from a form to another form with Alt + Tab, when I return with Alt + Tab to the original form the grid hat no more the focus und it is impossible to set the focus even with the mouse.

If I move form a form to another form with the mouse in the Status Bar, the problem doesn't appear.

With Lazarus 0.9.28.2 all worked great.

Best regards,

Stefano

Jesus Reyes

2011-08-22 19:30

developer   ~0051025

Have you tried with a more recent version, with a snapshot for example? if not please try it.

Stefano

2011-08-23 15:58

reporter   ~0051051

Today I have tried with Snapshot, unfortunately I got problem with install: FPC is ok, after Lazarus installation there are 2 domaged packets (Lazarus) und Synaptic propose to remove Lazarus. This either with 0.9.30.1 or with 0.9.31 snapshots.

Could you test if the DbGrid work gut unter Linux with snapshot version?

Now I have reinstalled Lazarus 0.9.30.

Thank you for your reply.

Best regards,

Stefano

Jesus Reyes

2011-08-23 22:40

developer   ~0051057

> Could you test if the DbGrid work gut unter Linux with snapshot version?

I usually test under windows and linux with svn version, if you want to try svn version, there are multiple guides specially in wiki and forum, including my own account on it http://jesusrmx.blogspot.com/2009/06/actualizando-lazarus-mediante-svn.html

Stefano

2011-08-25 06:15

reporter   ~0051097

Thank you, your guide is very good. Unfortunately now I have not enough time to try install svn version, I bin very busy with my work. I've reinstalled Lazarus 0.9.28, this work good.

I will try again with Lazarus 0.9.30.2 when released.

However, I hope, that this issue is useful for you for the developement of the version 0.9.30.2 and 0.9.32.

Best regards,

Stefano

Stefano

2011-12-16 17:09

reporter   ~0055080

Today I have tried with 0.9.30.2 version. This version is better then 0.9.30, but there are still Problems.

1) With ScrollBars = ssVertical and AutoFillColumns = True the grid hat sometimes (when the Grid is complex with settings columns Visibile or not visible or columns width at runtime) eine wrong width, the different is = Width of the vertical bar.

2) The grid lost focus und I have to set SetFocus in my code to evoid the problem, especially if I work on then dataset (example: if I navigate in the dataset to calculate the total), after I have to make SetFocus.

With Lazarus 0.9.28.2 all worked perfect.

Best regards,

Stefano

Jesus Reyes

2012-09-22 20:07

developer   ~0062572

Hi, stefano, I'm taking a look into this and related issues, I'm sorry this is the case when I'm not able to reproduce the problem based on descriptions.

From 0.9.28 to 1.1 there have been a huge amount of changes, we need help to isolate what is causing this and related issues.

so please attach a simple project and instructions on how to reproduce them.

2012-09-23 02:10

 

MyTest.zip (54,124 bytes)

Stefano

2012-09-23 02:12

reporter   ~0062577

Hi Jesus Reyes, thanks for your reply, I attach a sample project to show the problems. I've updated the project, that I've added for bug n. 0022475, even for the problem of the with of the dbgrid. So in a single project you can see all the problems. The project uses a Firebird database with UIB/FBDataset in a module, and SQLDB in a 2. module, but you can easy addapt it for other Db.

The Form4 for UIB/FbDataSet is the most complete and you can even ignore the forms for SqlDb, that was limited to the Alt+Tab problem. Here you can see all the problems about the DbGrid + other:
-1) Bug 0019993/0022476: The problem of the CheckBox seems to be resolved in version 1.0, thanks.
-2) Bug 0019993: If you start "Form with UIB" and press Button GridAufill und then Button SetGrid, you see, the width difference = widht vertical scrollbar. When you press the Show button all returns ok. The problems seems due to setting the AutoFill property after the event Create of the Form (in my case from the calling form after the show) und then settng width of the dbgrid und then changing the Title.Caption. Without changing the Title.Caption the problem don't happens. Maybe it is pheraps possibile to bypass the problem by setting all the code in the Create event (better), aber in this way I could reproduce the same problem with a simple project. The same code worked well on version 0.9.28.2. With ssAutoVertical there are no problems.
-3) Bug 0019993/0022804: in version 1.0 the problem of the dbgrid that lost focus seems linked only to the Alt+Tab problem (bug 0022475), that is the most serious problem.
-4) Bug 0022475: In the sample you can see the Alt+Tab problem either for the DbGrid or for the DbEdit. When you move from the forms and return with Alt+Tab there are great problems to insert data into the DbGrid, above all in the currency (or float) fields, each character seems to replace the previous. You muss use the mouse in the Taskbar to resolve the problem. If you comment the CalcGrid in the DbGrid_KeyDown event (Key Arrow Up or Down) the situation seems to is better. When you move from the main fork to the form with the DbGrid the problem happens also for not currency fields. About DbEdit, if you move with Alt+Tab, the changes are lost.

In the mymainform.pas I've explained the problem a little better.

Sorry for my bad English.

Best regards,

Stefano

2012-09-23 16:25

 

MyTest_20120923.zip (180,461 bytes)

Stefano

2012-09-23 16:38

reporter   ~0062585

Last edited: 2012-11-22 13:52

Hello, I've updated the sample project, I've noted that there ware some problems to load it. I've simplified the code, commented the code not necessary to reproduce the problem and eliminated the unit that uses SQLDB.

So the test project is now easier und complete to show all the problems.

In the mymainform.pas I've explained all the problems.

I've added useful comments to the code.

If you don't wont to use Firebird and/or UIB/FbDataSet you can easy addapt the code to any other base data of your choice. I think to have isolated the problems, so the code is not long.

I've made also a short Video, that shows the test project running, and so it shows the problems. You can download this video in AVI format here:

http://www.studiocortelli.com/index.php?mod=28_Download&downloadfile=Software/ForExperts_Lazarus_TestDbGrid_20120923_Video.avi&mode=go

I think that now it is easier for you to reproduce the problem.

About bug 0019993, I think that the width problem occours when setting property AutoFillColumns = True at run time and then changing the Column.Title.Caption property, if ScrollBars are setted to ssVertical.

I've added the new project file even to bug 0022475. The sample projects shows in fact all these (different) problems.

Thank you for your time.

Best regards,

Stefano

Stefano

2012-10-29 16:40

reporter   ~0063545

Hello, the problem 1) remains with Lazarus 1.0.2. It seems to concern above all the Gtk2 -Linux interface. With the Qt interface the problem doesn't appear.

The problem 4) appears with Lazarus 1.0.2 with Mac/Carbon. With Linux/Gtk2 Lazarus works fine.

By the way, with Linux/Qt interface the Db grid lost often the focus. I'm testing better, may be I will open a specifed post for the problems of the Dbgrid on Qt/Linux, I've noted problems with Append and Post on Qt (the Dbgrid lost the current position in the dataset and goes on the first record), but I must identificate better the problems.

Best regards,

Stefano

Stefano

2012-10-29 16:40

reporter   ~0063546

Hello, the problem 1) remains with Lazarus 1.0.2. It seems to concern above all the Gtk2 -Linux interface. With the Qt interface the problem doesn't appear.

The problem 4) appears with Lazarus 1.0.2 with Mac/Carbon. With Linux/Gtk2 Lazarus works fine.

By the way, with Linux/Qt interface the Db grid lost often the focus. I'm testing better, may be I will open a specifed post for the problems of the Dbgrid on Qt/Linux, I've noted problems with Append and Post on Qt (the Dbgrid lost the current position in the dataset and goes on the first record), but I must identificate better the problems.

Best regards,

Stefano

Jesus Reyes

2012-11-21 01:18

developer   ~0063943

Problems 1) and 3) are now fixed, problem 2) cannot reproduce, the grid does remember the invisible column width and when it's made visible again, its previous size is restored, please check again, if you still can reproduce the problem please submit a new report for this issue with a updated test project.

About 4) your code seems to reproduce the effect of AutoAdvance=aaRightDown, but including the right arrow key when selection is in the last column, I don't now if this is supposed to work that way for DbGrid, for a StringGrid, Right arrow on last column does/should move selection to the next row, first non fixed column. If it should work that way in dbgrid, I think we need to fix aaRightDown for dbgrid too. Anyway, you have tried to implement your own aaRightDown in 4) but what I don't remember is if in v0.9.28 the condition (dbgrid3.SelectedIndex = dbgrid3.Columns.Count - 1) evaluates to true when the last visible column was not really the last column in grid, in your sample project the last column is invisible and this is the reason this condition is not true. As a help in this case, in r39319 I have implemented a couple of properties in DbGrid that may help here. Changing the condition to (dbgrid3.SelectedColumn = dbgrid3.LastColumn) should work. LastColumn returns the last visible column in dbgrid.

About 5) unfortunately without a test to reproduce I cannot fix it.

BTW, it would be nice if reports are made in such way that 1 problem=1 report, instead of many problems=1 report. If a test project helps to reproduce several problems, attaching the project to one and referencing it on the others should be enough.

So please try with a newer revision than r39319, or try to apply the patches on your current version, if it helps to solve the problems and do not have side effects, I think this patches are candidates to be merged to fixes and to be included in next release, primarily because they are purported regressions (I don't know if regressions agains to "not the last release" are really to be considered as valid regressions though)

Stefano

2012-11-22 13:46

reporter   ~0063968

Hi Jesus Reyes, thanks for your work. I think the 2 new properties are very useful. In any case with Lazarus 1.0 and 1.0.2 when the user insert oder edit data in the last cell of the row, the grid lost focus, also when the last cell is a visible and enabled column.

This happens either with Linux/GTK2, or with Linux/QT, or with Mac/Carbon.

I precise thant the dbgrid has no cell selection option. Maybe when dgEditing = True (oder a new property e.g. AllowCellSelection = False?) it would be useful, that the DbGrid doesn't lose focus when the user insert/modify data in the last columns of the row.

I think also the aaRightDown on the DbGrid woulde be appreciated.

Excuse me if I've written more bugs in the same report. My next reports will be always 1 issue = 1 bug (as I've made for the bugs of the DbGrid on Mac: 0023242, 0023243, 0023271, 0023273, 0023274).

Thank you again, best regards,

Stefano

Issue History

Date Modified Username Field Change
2011-08-16 12:11 Stefano New Issue
2011-08-16 12:11 Stefano Widgetset => GTK 2
2011-08-16 21:35 Jesus Reyes Status new => assigned
2011-08-16 21:35 Jesus Reyes Assigned To => Jesus Reyes
2011-08-17 17:11 Stefano Note Added: 0050907
2011-08-19 16:05 Stefano Note Added: 0050952
2011-08-22 19:30 Jesus Reyes LazTarget => -
2011-08-22 19:30 Jesus Reyes Note Added: 0051025
2011-08-22 19:30 Jesus Reyes Status assigned => feedback
2011-08-23 15:58 Stefano Note Added: 0051051
2011-08-23 22:40 Jesus Reyes Note Added: 0051057
2011-08-25 06:15 Stefano Note Added: 0051097
2011-12-16 17:09 Stefano Note Added: 0055080
2012-02-04 11:53 Zeljan Rikalo LazTarget - => 1.2
2012-07-22 09:50 Juha Manninen Relationship added related to 0022476
2012-09-22 20:07 Jesus Reyes Note Added: 0062572
2012-09-22 20:09 Jesus Reyes Relationship added related to 0022804
2012-09-23 02:10 Stefano File Added: MyTest.zip
2012-09-23 02:12 Stefano Note Added: 0062577
2012-09-23 16:25 Stefano File Added: MyTest_20120923.zip
2012-09-23 16:38 Stefano Note Added: 0062585
2012-10-29 16:40 Stefano Note Added: 0063545
2012-10-29 16:40 Stefano Note Added: 0063546
2012-11-21 01:18 Jesus Reyes Fixed in Revision => 39316, 39317
2012-11-21 01:18 Jesus Reyes Status feedback => resolved
2012-11-21 01:18 Jesus Reyes Fixed in Version => 1.1 (SVN)
2012-11-21 01:18 Jesus Reyes Resolution open => fixed
2012-11-21 01:18 Jesus Reyes Note Added: 0063943
2012-11-21 01:19 Jesus Reyes Target Version => 1.2.0
2012-11-22 13:46 Stefano Note Added: 0063968
2012-11-22 13:52 Stefano Note Edited: 0062585