![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Выделение строк в ListBox [D7, XP]
Саша © (2008-07-01 13:41:00)Подскажите пожалуйста, мастера, как выделить дублирующие по содержанию строки в ListBox.
я попробывал вот таким кодом, но им не получается-удаляются все одинаковые.
for i:=0 to listbox1.Items.Count-1 do begin
for j:=1 to listbox1.Items.Count-1 do
if listbox1.Items[i]=listbox1.Items[j] then begin
listbox1.Selected[j]:=true;
end; end;
Игорь Шевченко (2008-07-01 14:07:00) [1]немножко пошустрее:
function FindDuplicates (Start: Integer): Boolean;
var
I: Integer;
begin
Result := false;
for I := Succ(Start) to ListBox1.Items.Count - 1 do
if not ListBox1.Selected[I]
and (ListBox1.Items[I] = ListBox1.Items[Start]) then
begin
Result := true;
ListBox1.Selected[I] := true;
end;
end;
var
I: Integer;
begin
for I := 0 to ListBox1.Items.Count - 1 do
if not ListBox1.Selected[I] then
if FindDuplicates(I) then
ListBox1.Selected[I] := true;
end;
oldman (2008-07-01 14:03:00) [2]
> alexBlack © (01.07.08 13:54) [1]
> по-моему нужно при сравнении исключать случай i=j
не for j:=1, a
for j:=i+1 to
alexBlack (2008-07-01 13:54:00) [3]по-моему нужно при сравнении исключать случай i=j