Вниз
Скачать: CL | DM;

Listbox pt.2   Найти похожие ветки 

← →
Bobby Digital ©   (2004-11-28 05:25) [0]

А можно ли как то в Listbox перетаскивать елементы чтоб менялся их индекс. Т.е. взть строку с Индексом 0 .. и перетянуть на строку 3


← →
PZ   (2004-11-28 12:12) [1]

Один из вариантов решения может быть таков:

Var
 Ind : Integer;
 S : String;

procedure TForm1.ListBox1MouseDown(Sender: TObject; Button: TMouseButton;
 Shift: TShiftState; X, Y: Integer);

begin
 Ind := ListBox1.ItemIndex;
 S := ListBox1.Items.Strings[Ind];
end;

procedure TForm1.ListBox1MouseUp(Sender: TObject; Button: TMouseButton;
 Shift: TShiftState; X, Y: Integer);
Var
 I : Integer;
begin
 I := ListBox1.ItemIndex;
 ListBox1.Items.Insert(I, S);
 ListBox1.Items.Delete(Ind);
end;


← →
Bobby Digital ©   (2004-11-28 12:41) [2]


> PZ  

нет это неверное решение ... потому что функия Insert  заменяет один элемент на второй, а не меняет их местами. Тут нужно использовать функцию Move

var
_index: integer;

procedure TForm4.ListBox1MouseDown(Sender: TObject; Button: TMouseButton;
 Shift: TShiftState; X, Y: Integer);
begin
_index := ListBox1.ItemIndex;
end;

procedure TForm4.ListBox1MouseUp(Sender: TObject; Button: TMouseButton;
 Shift: TShiftState; X, Y: Integer);

var
 i:integer;
 begin
I := ListBox1.ItemIndex;
ListBox1.Items.Move(_index,i);
Listbox2.Items.Add(" + ");
end;


но ... MouseUp не сосвем походит,  а есть ли какое-нибудь событие которое возникает при выделении элемента?


← →
Bobby Digital ©   (2004-11-28 12:43) [3]

в смысле выделения елемента Listbox`a


← →
begin...end ©   (2004-11-28 13:19) [4]

> [2] Bobby Digital ©   (28.11.04 12:41)

> потому что функия Insert  заменяет один элемент на второй

Вы в этом уверены?


← →
Bobby Digital ©   (2004-11-28 13:23) [5]

to begin...end

в примере приведенном PZ - да !



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.45 MB
Время: 0.026 c
3-1100182085
}|{yk
2004-11-11 17:08
2004.12.12
Инвалидность объектов в Firebird


1-1101825652
denis24
2004-11-30 17:40
2004.12.12
месяц словом


3-1100504182
wHammer
2004-11-15 10:36
2004.12.12
Возможно ли восстановление?


1-1101401049
Руслана
2004-11-25 19:44
2004.12.12
Почему BlockWrite(SaveFile, D, 4) вызывает предупреждение


1-1101640633
serko
2004-11-28 14:17
2004.12.12
DateTimePicker




   Наверх