View Issue Details

IDProjectCategoryView StatusLast Update
0022789LazarusLCLpublic2014-01-08 10:40
ReporterLacaKAssigned ToJesus Reyes 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version1.0.1 (SVN)Product Build 
Target Version1.2.0Fixed in Version1.1 (SVN) 
Summary0022789: [Patch] TDBGrid, for some field types inplace editor incorrectly sets MaxLength
DescriptionThere is in procedure TCustomDBGrid.SelectEditor done setting of MaxLength for TStringFields when InplaceEditor is selected.

Problem is when we tab from "string field" to not "string field" (for example numeric field). In this case MaxLength is not reset and remains last set-ed.

So when we move from char(1) column to integer column, then only one digit can be typed into integer column.

Patch resets MaxLength to 0 if SelectedField is not TStringField.
TagsNo tags attached.
Fixed in Revision38618
LazTarget1.2
Widgetset
Attached Files
  • dbgrids.pas.diff (1,130 bytes)
    --- dbgrids.pas.ori	Tue Sep 04 13:10:42 2012
    +++ dbgrids.pas	Tue Sep 04 13:37:36 2012
    @@ -2400,6 +2400,7 @@ end;
     procedure TCustomDBGrid.SelectEditor;
     var
       aEditor: TWinControl;
    +  aMaxLen: integer;
     begin
       {$ifdef dbgDBGrid}
       DebugLn('TCustomDBGrid.SelectEditor INIT Editor=',dbgsname(editor));
    @@ -2407,13 +2408,16 @@ begin
       if (FDatalink<>nil) and FDatalink.Active then begin
         inherited SelectEditor;
     
    -    if (SelectedField is TStringField) then begin
    -      if (Editor is TCustomEdit) then
    -        TCustomEdit(Editor).MaxLength := SelectedField.Size
    -      else
    -      if (Editor is TCompositeCellEditor) then
    -        TCompositeCellEditor(Editor).MaxLength := SelectedField.Size;
    -    end;
    +    if (SelectedField is TStringField) then
    +      aMaxLen := SelectedField.Size
    +    else
    +      aMaxLen := 0;
    +
    +    if (Editor is TCustomEdit) then
    +      TCustomEdit(Editor).MaxLength := aMaxLen
    +    else
    +    if (Editor is TCompositeCellEditor) then
    +      TCompositeCellEditor(Editor).MaxLength := aMaxLen;
     
         if Assigned(OnSelectEditor) then begin
           aEditor:=Editor;
    
    dbgrids.pas.diff (1,130 bytes)

Relationships

has duplicate 0023242 resolvedJesus Reyes Mac Os X - Carbon: TDbGrid manteins Max Field Size of the last string column 
child of 0022812 resolvedJesus Reyes TDBGrid input of BCD Fields too short 

Activities

2012-09-04 13:53

 

dbgrids.pas.diff (1,130 bytes)
--- dbgrids.pas.ori	Tue Sep 04 13:10:42 2012
+++ dbgrids.pas	Tue Sep 04 13:37:36 2012
@@ -2400,6 +2400,7 @@ end;
 procedure TCustomDBGrid.SelectEditor;
 var
   aEditor: TWinControl;
+  aMaxLen: integer;
 begin
   {$ifdef dbgDBGrid}
   DebugLn('TCustomDBGrid.SelectEditor INIT Editor=',dbgsname(editor));
@@ -2407,13 +2408,16 @@ begin
   if (FDatalink<>nil) and FDatalink.Active then begin
     inherited SelectEditor;
 
-    if (SelectedField is TStringField) then begin
-      if (Editor is TCustomEdit) then
-        TCustomEdit(Editor).MaxLength := SelectedField.Size
-      else
-      if (Editor is TCompositeCellEditor) then
-        TCompositeCellEditor(Editor).MaxLength := SelectedField.Size;
-    end;
+    if (SelectedField is TStringField) then
+      aMaxLen := SelectedField.Size
+    else
+      aMaxLen := 0;
+
+    if (Editor is TCustomEdit) then
+      TCustomEdit(Editor).MaxLength := aMaxLen
+    else
+    if (Editor is TCompositeCellEditor) then
+      TCompositeCellEditor(Editor).MaxLength := aMaxLen;
 
     if Assigned(OnSelectEditor) then begin
       aEditor:=Editor;
dbgrids.pas.diff (1,130 bytes)

Jesus Reyes

2012-09-11 21:18

developer   ~0062295

Applied, Thank you.

Issue History

Date Modified Username Field Change
2012-09-04 13:53 LacaK New Issue
2012-09-04 13:53 LacaK File Added: dbgrids.pas.diff
2012-09-06 07:06 Jesus Reyes Status new => assigned
2012-09-06 07:06 Jesus Reyes Assigned To => Jesus Reyes
2012-09-11 21:18 Jesus Reyes Fixed in Revision => 38618
2012-09-11 21:18 Jesus Reyes LazTarget => 1.2
2012-09-11 21:18 Jesus Reyes Status assigned => resolved
2012-09-11 21:18 Jesus Reyes Fixed in Version => 1.1 (SVN)
2012-09-11 21:18 Jesus Reyes Resolution open => fixed
2012-09-11 21:18 Jesus Reyes Note Added: 0062295
2012-09-11 21:18 Jesus Reyes Target Version => 1.2.0
2012-09-12 07:11 LacaK Status resolved => closed
2012-10-08 04:21 Jesus Reyes Relationship added child of 0022812
2014-01-08 10:40 Jesus Reyes Relationship added has duplicate 0023242