View Issue Details

IDProjectCategoryView StatusLast Update
0035715LazarusLCLpublic2020-04-02 12:14
ReporterLuca Olivetti Assigned ToJuha Manninen  
Status closedResolutionfixed 
Product Version2.0.2 
Summary0035715: [PATCH] TDBGrid get editor alignment from wrong column if FixedCells>1
DescriptionIn a TDBGrid with the option dgIndicator on, settings FixedCells to, e.g., 2 (so that the indicator column and the first data column are fixed), the alignment for the editor is taken from the wrong column.
In the example project, there are 3 column, the first one is fixed, the second is right aligned and the third is left aligned.
If you enter the cell of the 3rd field it is right aligned (it got the alignment from the second column).
The patch seems to fix the issue but I'm not sure it's the best solution (the grids are soooo complex).
The checkbox in the project is to show another but I'm reporting next.

TagsNo tags attached.
Fixed in Revisionr62847
Attached Files


Luca Olivetti

2019-06-13 16:47

reporter (128,824 bytes)
gridbug.patch (822 bytes)   
Index: lcl/grids.pas
--- lcl/grids.pas	(revision 61054)
+++ lcl/grids.pas	(working copy)
@@ -7075,6 +7075,7 @@
 procedure TCustomGrid.DoEditorShow;
   ParentChanged: Boolean;
+  Column: TGridColumn;
   {$ifdef dbgGrid}DebugLnEnter('grid.DoEditorShow [',Editor.ClassName,'] INIT');{$endif}
   ScrollToCell(FCol,FRow, True);
@@ -7091,8 +7092,9 @@
   if (FEditor = FStringEditor) or (FEditor = FButtonStringEditor) then
-    if FCol-FFixedCols<Columns.Count then
-      FStringEditor.Alignment:=Columns[FCol-FFixedCols].Alignment
+    Column:=ColumnFromGridColumn(FCol);
+    if Column<>nil then
+      FStringEditor.Alignment:=Column.Alignment
gridbug.patch (822 bytes)   

Luca Olivetti

2020-04-02 10:24

reporter   ~0121835

Could somebody take a look at this? I checked both trunk and the fixes_2_0 branch and it still uses the same logic for the editor alignment. I have been using this patch since I reported it with apparently no ill effects.

Juha Manninen

2020-04-02 12:09

developer   ~0121839

I tested and applied the patch. Looks good. This can be merged to fixes_2_0.

Luca Olivetti

2020-04-02 12:14

reporter   ~0121840

Thank you

Issue History

Date Modified Username Field Change
2019-06-13 16:47 Luca Olivetti New Issue
2019-06-13 16:47 Luca Olivetti File Added:
2019-06-13 16:47 Luca Olivetti File Added: gridbug.patch
2019-06-13 18:40 Jesus Reyes Assigned To => Jesus Reyes
2019-06-13 18:40 Jesus Reyes Status new => assigned
2020-04-02 10:24 Luca Olivetti Note Added: 0121835
2020-04-02 11:51 Juha Manninen Assigned To Jesus Reyes => Juha Manninen
2020-04-02 12:09 Juha Manninen Status assigned => resolved
2020-04-02 12:09 Juha Manninen Resolution open => fixed
2020-04-02 12:09 Juha Manninen Fixed in Revision => r62847
2020-04-02 12:09 Juha Manninen LazTarget => -
2020-04-02 12:09 Juha Manninen Note Added: 0121839
2020-04-02 12:14 Luca Olivetti Status resolved => closed
2020-04-02 12:14 Luca Olivetti Note Added: 0121840