mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-02 10:20:29 +02:00
* Patch from Yury Sidorov for clearing a listview selection
git-svn-id: trunk@10678 -
This commit is contained in:
parent
5a848bbc23
commit
57d06e746d
@ -798,15 +798,36 @@ end;
|
|||||||
TCustomListView SetSelection
|
TCustomListView SetSelection
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
procedure TCustomListView.SetSelection(const AValue: TListItem);
|
procedure TCustomListView.SetSelection(const AValue: TListItem);
|
||||||
|
var
|
||||||
|
i: integer;
|
||||||
begin
|
begin
|
||||||
if (AValue<>nil) and (AValue.ListView<>Self) then
|
if (AValue<>nil) and (AValue.ListView<>Self) then
|
||||||
raise Exception.Create('item does not belong to this listview');
|
raise Exception.Create('item does not belong to this listview');
|
||||||
if FSelected = AValue then Exit;
|
if FSelected = AValue then Exit;
|
||||||
FSelected := AValue;
|
|
||||||
//DebugLn('TCustomListView.SetSelection FSelected=',dbgs(FSelected));
|
//DebugLn('TCustomListView.SetSelection FSelected=',dbgs(FSelected));
|
||||||
if not HandleAllocated then Exit;
|
if AValue = nil then begin
|
||||||
TWSCustomListViewClass(WidgetSetClass).ItemSetState(Self, FSelected.Index,
|
if MultiSelect then begin
|
||||||
FSelected, lisSelected, True);
|
BeginUpdate;
|
||||||
|
try
|
||||||
|
for i:=0 to Items.Count-1 do
|
||||||
|
with Items[i] do
|
||||||
|
if Selected then
|
||||||
|
Selected:=False;
|
||||||
|
finally
|
||||||
|
EndUpdate;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
FSelected.Selected := False;
|
||||||
|
FSelected := nil;
|
||||||
|
Include(FFlags,lffSelectedValid);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
FSelected := AValue;
|
||||||
|
if HandleAllocated then
|
||||||
|
TWSCustomListViewClass(WidgetSetClass).ItemSetState(Self, FSelected.Index,
|
||||||
|
FSelected, lisSelected, True);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomListView.SetOwnerData(const AValue: Boolean);
|
procedure TCustomListView.SetOwnerData(const AValue: Boolean);
|
||||||
|
Loading…
Reference in New Issue
Block a user