From 20dee3aee0ae42a874175a3cafb21ce86b21ea82 Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 9 Jan 2008 10:11:37 +0000 Subject: [PATCH] + TCustomListbox.ClearSelection git-svn-id: trunk@13682 - --- lcl/include/customlistbox.inc | 26 ++++++++++++++++++++------ lcl/stdctrls.pp | 1 + 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/lcl/include/customlistbox.inc b/lcl/include/customlistbox.inc index dc7138f19b..5b2b49d4bc 100644 --- a/lcl/include/customlistbox.inc +++ b/lcl/include/customlistbox.inc @@ -323,14 +323,17 @@ procedure TCustomListBox.SetSelected(Index : integer; Val : boolean); begin CheckIndex(Index); - if not MultiSelect then begin + if not MultiSelect then + begin if Val then - ItemIndex:=Index - else if Index=ItemIndex then - ItemIndex:=-1; - end else begin + ItemIndex := Index + else + if Index = ItemIndex then + ItemIndex := -1; + end else + begin if HandleAllocated - then SendItemSelected(Index,Val) + then SendItemSelected(Index, Val) else PCustomListBoxItemRecord(GetCachedData(Index))^.Selected := Val; end; end; @@ -555,6 +558,17 @@ begin FItems.Clear; end; +procedure TCustomListBox.ClearSelection; +var + i: integer; +begin + if MultiSelect then + for i := 0 to Items.Count - 1 do + Selected[i] := False + else + ItemIndex := -1; // no need to traverse all items - look at SetSelected +end; + procedure TCustomListBox.LockSelectionChange; begin inc(FLockSelectionChange); diff --git a/lcl/stdctrls.pp b/lcl/stdctrls.pp index 7a53a791d5..ea4ae82afe 100644 --- a/lcl/stdctrls.pp +++ b/lcl/stdctrls.pp @@ -524,6 +524,7 @@ type procedure MakeCurrentVisible; procedure MeasureItem(Index: Integer; var TheHeight: Integer); virtual; procedure Clear; virtual; + procedure ClearSelection; procedure LockSelectionChange; procedure UnlockSelectionChange; procedure Click; override; // make it public