diff --git a/Demos/Advanced/Advanced.dproj b/Demos/Advanced/Advanced.dproj
index b29276705..d58c96f90 100644
--- a/Demos/Advanced/Advanced.dproj
+++ b/Demos/Advanced/Advanced.dproj
@@ -7,7 +7,7 @@
1
Application
VCL
- 18.5
+ 19.0
Win32
@@ -77,6 +77,7 @@
CompanyName=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName);ProductName=$(MSBuildProjectName)
true
PerMonitorV2
+ Debug
diff --git a/Source/VirtualTrees.pas b/Source/VirtualTrees.pas
index 8c27b2b2d..d1faaf6a3 100644
--- a/Source/VirtualTrees.pas
+++ b/Source/VirtualTrees.pas
@@ -1310,8 +1310,8 @@ TVTHeader = class(TPersistent)
FSortColumn: TColumnIndex;
FSortDirection: TSortDirection;
FDragImage: TVTDragImage; // drag image management during header drag
- FLastWidth: TDimension; // Used to adjust spring columns. This is the width of all visible columns,
- // not the header rectangle.
+ FLastWidth: TDimension; // Used to adjust spring columns. This is the width of all visible columns, not the header rectangle.
+ FRestoreSelectionColumnIndex: Integer; // The column that is used to implement the coRestoreSelection option
function GetMainColumn: TColumnIndex;
function GetUseColumns: Boolean;
function IsFontStored: Boolean;
@@ -1330,6 +1330,7 @@ TVTHeader = class(TPersistent)
procedure SetSortColumn(Value: TColumnIndex);
procedure SetSortDirection(const Value: TSortDirection);
procedure SetStyle(Value: TVTHeaderStyle);
+ function GetRestoreSelectionColumnIndex: Integer;
protected
FStates: THeaderStates; // Used to keep track of internal states the header can enter.
FDragStart: TPoint; // initial mouse drag position
@@ -1389,6 +1390,7 @@ TVTHeader = class(TPersistent)
procedure SaveToStream(const Stream: TStream); virtual;
property DragImage: TVTDragImage read FDragImage;
+ property RestoreSelectionColumnIndex: Integer read GetRestoreSelectionColumnIndex write fRestoreSelectionColumnIndex default NoColumn;
property States: THeaderStates read FStates;
property Treeview: TBaseVirtualTree read FOwner;
property UseColumns: Boolean read GetUseColumns;
@@ -10293,6 +10295,14 @@ function TVTHeader.GetOwner: TPersistent;
Result := FOwner;
end;
+function TVTHeader.GetRestoreSelectionColumnIndex: Integer;
+begin
+ if fRestoreSelectionColumnIndex >= 0 then
+ Result := fRestoreSelectionColumnIndex
+ else
+ Result := MainColumn;
+end;
+
//----------------------------------------------------------------------------------------------------------------------
function TVTHeader.GetShiftState: TShiftState;
@@ -33810,7 +33820,7 @@ function TCustomVirtualStringTree.AddChild(Parent: PVirtualNode; UserData: Point
if (toRestoreSelection in TreeOptions.SelectionOptions) and Assigned(FPreviouslySelected) and Assigned(OnGetText) then
begin
// See if this was the previously selected node and restore it in this case
- Self.OnGetText(Self, Result, 0, ttNormal, NewNodeText);
+ Self.OnGetText(Self, Result, Header.RestoreSelectionColumnIndex, ttNormal, NewNodeText);
if FPreviouslySelected.IndexOf(NewNodeText) >= 0 then
begin
// Select this node and make sure that the parent node is expanded