View Issue Details

IDProjectCategoryView StatusLast Update
0025116LazarusLCLpublic2015-07-16 08:43
ReporterMiroslav NyameshchukAssigned ToJesus Reyes 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformWinOSOS Version
Product Version1.1 (SVN)Product Build43040 
Target Version1.6Fixed in Version1.5 (SVN) 
Summary0025116: StringGrid.Columns[].Title.Caption not set empty value
DescriptionStringGrid.Columns[].Title.Caption not set empty value in object inspector.
If setting - changing to 'Title'
TagsNo tags attached.
Fixed in Revision49040
LazTarget1.6
WidgetsetWin32/Win64
Attached Files
  • grids.pas(DefaultCaption).patch (3,222 bytes)
    Index: lcl/grids.pas
    ===================================================================
    --- lcl/grids.pas	(revision 46308)
    +++ lcl/grids.pas	(working copy)
    @@ -663,6 +663,7 @@
         FAutoEdit: boolean;
         FAutoFillColumns: boolean;
         FBorderColor: TColor;
    +    FDefaultCaption: String;
         FDefaultDrawing: Boolean;
         FEditor: TWinControl;
         FEditorHidingCount: Integer;
    @@ -752,6 +753,7 @@
         procedure CheckCount(aNewColCount, aNewRowCount: Integer; FixEditor: boolean=true);
         procedure CheckIndex(IsColumn: Boolean; Index: Integer);
         function  CheckTopLeft(aCol,aRow: Integer; CheckCols,CheckRows: boolean): boolean;
    +    function  GetDefaultCaption: String;
         function  IsCellButtonColumn(ACell: TPoint): boolean;
         function  GetSelectedColumn: TGridColumn;
         function  IsDefRowHeightStored: boolean;
    @@ -761,6 +763,7 @@
         procedure SetBorderColor(const AValue: TColor);
         procedure SetColumnClickSorts(const AValue: boolean);
         procedure SetColumns(const AValue: TGridColumns);
    +    procedure SetDefaultCaption(AValue: String);
         procedure SetEditorOptions(const AValue: Integer);
         procedure SetEditorBorderStyle(const AValue: TBorderStyle);
         procedure SetAltColorStartNormal(const AValue: boolean);
    @@ -1073,6 +1076,7 @@
         property ColumnClickSorts: boolean read FColumnClickSorts write SetColumnClickSorts default false;
         property Columns: TGridColumns read GetColumns write SetColumns stored IsColumnsStored;
         property ColWidths[aCol: Integer]: Integer read GetColWidths write SetColWidths;
    +    property DefaultCaption: String read GetDefaultCaption write SetDefaultCaption;
         property DefaultColWidth: Integer read FDefColWidth write SetDefColWidth default DEFCOLWIDTH;
         property DefaultRowHeight: Integer read FDefRowHeight write SetDefRowHeight stored IsDefRowHeightStored;
         property DefaultDrawing: Boolean read FDefaultDrawing write SetDefaultDrawing default True;
    @@ -1617,6 +1621,7 @@
         property ColumnClickSorts;
         property Columns;
         property Constraints;
    +    property DefaultCaption;
         property DefaultColWidth;
         property DefaultDrawing;
         property DefaultRowHeight;
    @@ -4920,6 +4925,11 @@
         doTopleftChange(False)
     end;
     
    +function TCustomGrid.GetDefaultCaption: String;
    +begin
    +  Result := FDefaultCaption;
    +end;
    +
     function TCustomGrid.IsCellButtonColumn(ACell: TPoint): boolean;
     var
       Column: TGridColumn;
    @@ -5042,6 +5052,11 @@
       FColumns.Assign(Avalue);
     end;
     
    +procedure TCustomGrid.SetDefaultCaption(AValue: String);
    +begin
    +  FDefaultCaption := AValue;
    +end;
    +
     procedure TCustomGrid.SetEditorOptions(const AValue: Integer);
     begin
       if FEditorOptions<>AValue then begin
    @@ -8724,6 +8739,7 @@
          goSmoothScroll ];
       FScrollbars:=ssAutoBoth;
       fGridState:=gsNormal;
    +  FDefaultCaption := 'Title';
       FDefColWidth:=DEFCOLWIDTH;
       FDefRowHeight:=GetDefaultRowHeight;
       FGridLineColor:=clSilver;
    @@ -10957,7 +10973,10 @@
     
     function TGridColumnTitle.GetDefaultCaption: string;
     begin
    -  Result := 'Title'
    +  if FColumn.Grid<>nil then
    +    result := FColumn.Grid.DefaultCaption
    +  else
    +    result := 'Title';
     end;
     
     function TGridColumnTitle.GetDefaultAlignment: TAlignment;
    

Relationships

related to 0027703 resolvedJesus Reyes Problem Editing with TDBGridColumn Title.Caption Editor 

Activities

Bart Broersma

2013-09-30 18:00

developer   ~0070458

It does not work at runtime either.
An empty string will set the caption to 'Title'.

Jesus Reyes

2013-10-01 22:24

developer   ~0070481

The problem is that internally an empty string is the default caption, and when the ColumnTitle asks for it's caption and it's default, it returns a default 'Title' string.

It has not high priority, if you want to simulate this, use a ' ' space and check for a ' ' space for empty column title, not ideal but ATM is the only way.

When fixed, that should work also :)

Bart Broersma

2013-10-16 23:35

developer   ~0070848

Last edited: 2013-10-16 23:36

View 2 revisions

We could introduce a published property TGridColumnTitle.DefaultCaption and set it to 'Title' by default and then

function TGridColumnTitle.GetDefaultCaption: string;
begin
  Result := FDefaultCaption;
end;

Bart Broersma

2013-12-07 14:10

developer   ~0071805

@Jesus: any objections to my proposal?
If not, I can implement and commit it.

Jesus Reyes

2014-01-08 08:56

developer   ~0072296

I'm sorry, I tried many ways too. As I said, it's not high priority but if you find a good way, please do it.

Jesus Reyes

2014-09-24 01:01

developer   ~0077574

@Bart, please before committing, send me first the patch to check it.

Mike Thompson

2014-09-25 09:48

developer  

grids.pas(DefaultCaption).patch (3,222 bytes)
Index: lcl/grids.pas
===================================================================
--- lcl/grids.pas	(revision 46308)
+++ lcl/grids.pas	(working copy)
@@ -663,6 +663,7 @@
     FAutoEdit: boolean;
     FAutoFillColumns: boolean;
     FBorderColor: TColor;
+    FDefaultCaption: String;
     FDefaultDrawing: Boolean;
     FEditor: TWinControl;
     FEditorHidingCount: Integer;
@@ -752,6 +753,7 @@
     procedure CheckCount(aNewColCount, aNewRowCount: Integer; FixEditor: boolean=true);
     procedure CheckIndex(IsColumn: Boolean; Index: Integer);
     function  CheckTopLeft(aCol,aRow: Integer; CheckCols,CheckRows: boolean): boolean;
+    function  GetDefaultCaption: String;
     function  IsCellButtonColumn(ACell: TPoint): boolean;
     function  GetSelectedColumn: TGridColumn;
     function  IsDefRowHeightStored: boolean;
@@ -761,6 +763,7 @@
     procedure SetBorderColor(const AValue: TColor);
     procedure SetColumnClickSorts(const AValue: boolean);
     procedure SetColumns(const AValue: TGridColumns);
+    procedure SetDefaultCaption(AValue: String);
     procedure SetEditorOptions(const AValue: Integer);
     procedure SetEditorBorderStyle(const AValue: TBorderStyle);
     procedure SetAltColorStartNormal(const AValue: boolean);
@@ -1073,6 +1076,7 @@
     property ColumnClickSorts: boolean read FColumnClickSorts write SetColumnClickSorts default false;
     property Columns: TGridColumns read GetColumns write SetColumns stored IsColumnsStored;
     property ColWidths[aCol: Integer]: Integer read GetColWidths write SetColWidths;
+    property DefaultCaption: String read GetDefaultCaption write SetDefaultCaption;
     property DefaultColWidth: Integer read FDefColWidth write SetDefColWidth default DEFCOLWIDTH;
     property DefaultRowHeight: Integer read FDefRowHeight write SetDefRowHeight stored IsDefRowHeightStored;
     property DefaultDrawing: Boolean read FDefaultDrawing write SetDefaultDrawing default True;
@@ -1617,6 +1621,7 @@
     property ColumnClickSorts;
     property Columns;
     property Constraints;
+    property DefaultCaption;
     property DefaultColWidth;
     property DefaultDrawing;
     property DefaultRowHeight;
@@ -4920,6 +4925,11 @@
     doTopleftChange(False)
 end;
 
+function TCustomGrid.GetDefaultCaption: String;
+begin
+  Result := FDefaultCaption;
+end;
+
 function TCustomGrid.IsCellButtonColumn(ACell: TPoint): boolean;
 var
   Column: TGridColumn;
@@ -5042,6 +5052,11 @@
   FColumns.Assign(Avalue);
 end;
 
+procedure TCustomGrid.SetDefaultCaption(AValue: String);
+begin
+  FDefaultCaption := AValue;
+end;
+
 procedure TCustomGrid.SetEditorOptions(const AValue: Integer);
 begin
   if FEditorOptions<>AValue then begin
@@ -8724,6 +8739,7 @@
      goSmoothScroll ];
   FScrollbars:=ssAutoBoth;
   fGridState:=gsNormal;
+  FDefaultCaption := 'Title';
   FDefColWidth:=DEFCOLWIDTH;
   FDefRowHeight:=GetDefaultRowHeight;
   FGridLineColor:=clSilver;
@@ -10957,7 +10973,10 @@
 
 function TGridColumnTitle.GetDefaultCaption: string;
 begin
-  Result := 'Title'
+  if FColumn.Grid<>nil then
+    result := FColumn.Grid.DefaultCaption
+  else
+    result := 'Title';
 end;
 
 function TGridColumnTitle.GetDefaultAlignment: TAlignment;

Mike Thompson

2014-09-25 09:51

developer   ~0077631

Last edited: 2014-10-06 20:04

View 3 revisions

I have added a patch that adds a DefaultCaption property to TCustomGrid, which is called by TGridColumnTitle.GetDefaultCaption.
StringGrid is the only grid for which I've exposed this property (doesn't make sense for DBGrid, and I'm uncertain about DrawGrid usage)

EDIT: Didn't make sense to me to store DefaultCaption at the GridColumn level. In truth, the whole concept of a DefaultCaption for a Grid doesn't make sense to me (other than having something there while the user defines his columns), but this way the end user can set a Column Caption to '' if he wants, which was the original point of this issue.

Jesus Reyes

2015-05-16 05:29

developer   ~0083633

Thanks for the patch, I have implemented the fix in another way.
Please test.

Issue History

Date Modified Username Field Change
2013-09-30 11:37 Miroslav Nyameshchuk New Issue
2013-09-30 18:00 Bart Broersma LazTarget => -
2013-09-30 18:00 Bart Broersma Note Added: 0070458
2013-09-30 18:00 Bart Broersma Status new => confirmed
2013-10-01 22:19 Jesus Reyes Assigned To => Jesus Reyes
2013-10-01 22:19 Jesus Reyes Status confirmed => assigned
2013-10-01 22:24 Jesus Reyes Note Added: 0070481
2013-10-01 22:24 Jesus Reyes Target Version => 1.4
2013-10-16 23:35 Bart Broersma Note Added: 0070848
2013-10-16 23:36 Bart Broersma Note Edited: 0070848 View Revisions
2013-12-07 14:10 Bart Broersma Note Added: 0071805
2014-01-08 08:56 Jesus Reyes Note Added: 0072296
2014-09-24 01:01 Jesus Reyes Note Added: 0077574
2014-09-25 09:48 Mike Thompson File Added: grids.pas(DefaultCaption).patch
2014-09-25 09:51 Mike Thompson Note Added: 0077631
2014-10-06 20:03 Mike Thompson Note Edited: 0077631 View Revisions
2014-10-06 20:04 Mike Thompson Note Edited: 0077631 View Revisions
2015-05-07 06:45 Juha Manninen Target Version 1.4 =>
2015-05-15 22:04 Jesus Reyes Relationship added related to 0027703
2015-05-16 05:29 Jesus Reyes Fixed in Revision => 49040
2015-05-16 05:29 Jesus Reyes LazTarget - => 1.6
2015-05-16 05:29 Jesus Reyes Note Added: 0083633
2015-05-16 05:29 Jesus Reyes Status assigned => resolved
2015-05-16 05:29 Jesus Reyes Fixed in Version => 1.5 (SVN)
2015-05-16 05:29 Jesus Reyes Resolution open => fixed
2015-05-16 05:29 Jesus Reyes Target Version => 1.6
2015-07-16 08:43 Miroslav Nyameshchuk Status resolved => closed