線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1365
推到 Plurk!
推到 Facebook!

有關拖曳的問題

尚未結案
qq_911228
一般會員


發表:30
回覆:22
積分:10
註冊:2003-09-29

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-11-19 11:14:09 IP:218.164.xxx.xxx 未訂閱
Mickey
版主


發表:77
回覆:1882
積分:1390
註冊:2002-12-11

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-11-19 14:33:23 IP:218.163.xxx.xxx 未訂閱
qq_911228 你好:    試試看, 用 ItemIndex Property 來決定是否可 Drag :
procedure TForm1.ListBox1DragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
  Accept:=Listbox1.ItemIndex <> -1;
end;
不過, 我試了一下, 用 selected[i] 來判斷應該也行, 圖 1 的情況下 只是 Focus 並不是 select, 簡單測試 :
procedure TForm1.Button1Click(Sender: TObject);
begin
  if Listbox1.Selected[ListBox1.Items.IndexOf('Product')] then
    showmessage('Product Item Selected');
end;
並不會 Show Message.
qq_911228
一般會員


發表:30
回覆:22
積分:10
註冊:2003-09-29

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-11-19 15:29:41 IP:140.127.xxx.xxx 未訂閱
謝謝你~~ 不過我試了之後也是一樣~~ 很像他會自動assign第一筆為圈選了~~ 我用程式去徵測時,是跑出itemindex =-1,但拿掉這個判斷式, 而拖曳時,他又自動圈選第一筆~~~ 不知道這是什麼問題~~ 再麻煩你囉~~~    
引言: qq_911228 你好: 試試看, 用 ItemIndex Property 來決定是否可 Drag :
procedure TForm1.ListBox1DragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
  Accept:=Listbox1.ItemIndex <> -1;
end;
不過, 我試了一下, 用 selected[i] 來判斷應該也行, 圖 1 的情況下 只是 Focus 並不是 select, 簡單測試 :
procedure TForm1.Button1Click(Sender: TObject);
begin
  if Listbox1.Selected[ListBox1.Items.IndexOf('Product')] then
    showmessage('Product Item Selected');
end;
並不會 Show Message.
Mickey
版主


發表:77
回覆:1882
積分:1390
註冊:2002-12-11

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-11-19 16:38:28 IP:218.163.xxx.xxx 未訂閱
qq_911228 你好: 方便將 ListBox1.StartDrag/DragOver/DragDrop 等相關 Source Code. po 上來嗎.
qq_911228
一般會員


發表:30
回覆:22
積分:10
註冊:2003-09-29

發送簡訊給我
#5 引用回覆 回覆 發表時間:2003-11-19 18:06:42 IP:140.127.xxx.xxx 未訂閱
你好~~~因為我的multiselect設為true,所以會發生上述的情形, 如果我把multiselect設為false,則就沒有問題了, 但現在有一個問題,就是如果我每次有選多筆的話(multiselect:=true),就會有上述的問題,那請問要怎麼修改。謝謝。    //拖曳 procedure TForm1.DragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); var aa: tlistbox; begin //當ListBox項目拖曳經過目的地的listbox時會觸動此事件,此例為判斷如果拖曳進來是TListBox類別的物件,則允許拖曳進入 //Accept:=(Source is TListBox); aa := Source as TListBox;    //showmessage(vartostr(aa.Items.IndexOfName('customers'))); Accept:=aa.ItemIndex <> -1;    end;    procedure TForm1.DragDrop(Sender, Source: TObject; X, Y: Integer); var resource_list:TListBox; temp_list:TListBox; target_list : TListBox ; i :integer; begin //將ListBox的項目拖曳到目的地上放開滑鼠時觸動此事件 if(Source is TListBox) then begin    resource_list:=(Source as TListBox); target_list :=(Sender as TListBox); temp_list:=(Source as TListBox);    //temp_list.Clear; if (temp_list.ItemIndex <> -1) and (temp_list.Items.Count <> 0) then begin       target_list.Items.Add(temp_list.Items[temp_list.ItemIndex]);       resource_list.Items.Delete(temp_list.ItemIndex); end; end; end;    
引言: qq_911228 你好: 方便將 ListBox1.StartDrag/DragOver/DragDrop 等相關 Source Code. po 上來嗎.
發表人 - qq_911228 於 2003/11/19 18:30:03
Mickey
版主


發表:77
回覆:1882
積分:1390
註冊:2002-12-11

發送簡訊給我
#6 引用回覆 回覆 發表時間:2003-11-19 21:46:28 IP:218.32.xxx.xxx 未訂閱
嗯...原來是 MultiSelect 的關係... 試試看改用 SelCount 來決定 : Accept:=ListBox1.SelCount>0
系統時間:2024-05-18 12:14:19
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!