mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-20 09:39:13 +02:00
restore grid's custom columns after rowcount:=0, bug #6956
git-svn-id: trunk@9340 -
This commit is contained in:
parent
713f7851a3
commit
3fc416a384
@ -437,6 +437,12 @@ type
|
|||||||
property Visible: Boolean read GetVisible write SetVisible stored IsVisibleStored default true;
|
property Visible: Boolean read GetVisible write SetVisible stored IsVisibleStored default true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
TGridPropertyBackup=record
|
||||||
|
ValidData: boolean;
|
||||||
|
FixedRowCount: Integer;
|
||||||
|
FixedColCount: Integer;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TGridColumns }
|
{ TGridColumns }
|
||||||
|
|
||||||
TGridColumns = class(TCollection)
|
TGridColumns = class(TCollection)
|
||||||
@ -560,6 +566,7 @@ type
|
|||||||
FPrevValue: Integer;
|
FPrevValue: Integer;
|
||||||
FGridBorderStyle: TBorderStyle;
|
FGridBorderStyle: TBorderStyle;
|
||||||
FGridFlags: TGridFlags;
|
FGridFlags: TGridFlags;
|
||||||
|
FGridPropBackup: TGridPropertyBackup;
|
||||||
procedure AdjustCount(IsColumn:Boolean; OldValue, NewValue:Integer);
|
procedure AdjustCount(IsColumn:Boolean; OldValue, NewValue:Integer);
|
||||||
procedure CacheVisibleGrid;
|
procedure CacheVisibleGrid;
|
||||||
procedure CheckFixedCount(aCol,aRow,aFCol,aFRow: Integer);
|
procedure CheckFixedCount(aCol,aRow,aFCol,aFRow: Integer);
|
||||||
@ -1819,8 +1826,11 @@ begin
|
|||||||
if (OldValue=0)and(NewValue>=0) then begin
|
if (OldValue=0)and(NewValue>=0) then begin
|
||||||
FTopLeft.X:=FFixedCols;
|
FTopLeft.X:=FFixedCols;
|
||||||
if RowCount=0 then begin
|
if RowCount=0 then begin
|
||||||
FFixedRows:=0;
|
if Columns.Enabled then
|
||||||
FTopLeft.Y:=0;
|
FFixedRows := 1
|
||||||
|
else
|
||||||
|
FFixedRows := 0;
|
||||||
|
FTopLeft.Y:=FFixedRows;
|
||||||
//DebugLn('TCustomGrid.AdjustCount A ',DbgSName(Self),' FTopLeft=',dbgs(FTopLeft));
|
//DebugLn('TCustomGrid.AdjustCount A ',DbgSName(Self),' FTopLeft=',dbgs(FTopLeft));
|
||||||
AddDel(FRows, 1);
|
AddDel(FRows, 1);
|
||||||
FGCache.AccumHeight.Count:=1;
|
FGCache.AccumHeight.Count:=1;
|
||||||
@ -1863,6 +1873,22 @@ begin
|
|||||||
if AValue<1 then
|
if AValue<1 then
|
||||||
clear
|
clear
|
||||||
else begin
|
else begin
|
||||||
|
if (OldR=0) and Columns.Enabled then begin
|
||||||
|
// there are custom columns, setup first enough columns
|
||||||
|
if FGridPropBackup.ValidData then begin
|
||||||
|
// Take in count previus fixed columns too.
|
||||||
|
// This value will be used in ColumnsChanged get
|
||||||
|
// the right number of columns to setup
|
||||||
|
//
|
||||||
|
FFixedCols := FGridPropBackup.FixedColCount;
|
||||||
|
FGridPropBackup.ValidData:=False;
|
||||||
|
end;
|
||||||
|
// setup custom columns
|
||||||
|
Self.ColumnsChanged(nil);
|
||||||
|
// still need to adjust rowcount?
|
||||||
|
if AValue=FRows.Count then
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
CheckFixedCount(ColCount, AValue, FFixedCols, FFixedRows);
|
CheckFixedCount(ColCount, AValue, FFixedCols, FFixedRows);
|
||||||
CheckCount(ColCount, AValue);
|
CheckCount(ColCount, AValue);
|
||||||
AdjustCount(False, OldR, AValue);
|
AdjustCount(False, OldR, AValue);
|
||||||
@ -5901,6 +5927,12 @@ procedure TCustomGrid.Clear;
|
|||||||
var
|
var
|
||||||
OldR,OldC: Integer;
|
OldR,OldC: Integer;
|
||||||
begin
|
begin
|
||||||
|
// save some properties
|
||||||
|
FGridPropBackup.ValidData := True;
|
||||||
|
FGridPropBackup.FixedRowCount := FFixedRows;
|
||||||
|
FGridPropBackup.FixedColCount := FFixedCols;
|
||||||
|
|
||||||
|
// clear structure
|
||||||
OldR:=RowCount;
|
OldR:=RowCount;
|
||||||
OldC:=ColCount;
|
OldC:=ColCount;
|
||||||
FFixedCols:=0;
|
FFixedCols:=0;
|
||||||
|
Loading…
Reference in New Issue
Block a user