全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1589
推到 Plurk!
推到 Facebook!

如何將listview裡的縮圖移到listview2

答題得分者是:careychen
hungjeff
一般會員


發表:10
回覆:9
積分:3
註冊:2007-02-22

發送簡訊給我
#1 引用回覆 回覆 發表時間:2008-08-07 11:33:32 IP:140.128.xxx.xxx 訂閱
請問各位大大,我要將listview顯示的縮圖加入到listview2,請問該如何做呢?
下面的function可以將listview的縮圖加到listview2但是全都顯示listview1第一張的圖片,但是檔名是確定的,只是顯示的圖片都是第一張。

function MoveLvItem(lvOrig,lvdest:TlistView;checked:boolean=false):string;
var i,j:integer;
itemlist:TObjectlist;
listitem,newlistitem:TListItem;
begin
ItemList:=TObjectList.Create(false);
if not checked then
begin
for i:=lvOrig.Selected.Index to lvOrig.Items.Count -1 do
begin
if lvorig.Items[i].Selected then ItemList.Add(lvorig.Items[i]);
end;
end
else
begin
for i:=0 to lvorig.Items.Count -1 do
begin
if lvorig.Items[i].Checked then itemlist.Add(lvorig.Items[i]);
end;
end;
for i:=0 to itemlist.Count -1 do
begin
listitem:=itemList[i] as TlistItem;
newlistitem:= lvdest.Items.Add;
newlistitem.Caption:=listitem.Caption;
for j:= 0 to listitem.SubItems.Count -1 do
begin
newlistitem.SubItems.Add(listitem.SubItems[j]);
end;
end;
result:=(itemList[0] as TListItem).Caption;
(ItemList[0] as TlistItem).Delete;
for i:= 1 to ItemList.Count -1 do
begin
result:=Result ',' (Itemlist[-1] as TListItem).Caption;
(ItemList[1] as TListItem).Delete;
end;
ItemList.Free;
end;
careychen
尊榮會員


發表:41
回覆:580
積分:959
註冊:2004-03-03

發送簡訊給我
#2 引用回覆 回覆 發表時間:2008-08-07 19:08:56 IP:218.210.xxx.xxx 訂閱
請注意一下, lvDest 這個 listview 是不是有指定 LargeImages,SmallImages,StateImages 的相關屬性
如果有的話,請加下列那一行紅色的,應該就有了~!

===================引 用 hungjeff 文 章===================
請問各位大大,我要將listview顯示的縮圖加入到listview2,請問該如何做呢?
下面的function可以將listview的縮圖加到listview2但是全都顯示listview1第一張的圖片,但是檔名是確定的,只是顯示的圖片都是第一張。

function MoveLvItem(lvOrig,lvdest:TlistView;checked:boolean=false):string;
var i,j:integer;
itemlist:TObjectlist;
listitem,newlistitem:TListItem;
begin
ItemList:=TObjectList.Create(false);
if not checked then
begin
for i:=lvOrig.Selected.Index to lvOrig.Items.Count -1 do
begin
if lvorig.Items[i].Selected then ItemList.Add(lvorig.Items[i]);
end;
end
else
begin
for i:=0 to lvorig.Items.Count -1 do
begin
if lvorig.Items[i].Checked then itemlist.Add(lvorig.Items[i]);
end;
end;
for i:=0 to itemlist.Count -1 do
begin
listitem:=itemList[i] as TlistItem;
newlistitem:= lvdest.Items.Add;
newlistitem.ImageIndex := listitem.ImageIndex; // 加這行試試
newlistitem.Caption:=listitem.Caption;
for j:= 0 to listitem.SubItems.Count -1 do
begin
newlistitem.SubItems.Add(listitem.SubItems[j]);
end;
end;
result:=(itemList[0] as TListItem).Caption;
(ItemList[0] as TlistItem).Delete;
for i:= 1 to ItemList.Count -1 do
begin
result:=Result ',' (Itemlist[-1] as TListItem).Caption;
(ItemList[1] as TListItem).Delete;
end;
ItemList.Free;
end;
------
價值的展現,來自於你用哪一個角度來看待它!!
編輯記錄
careychen 重新編輯於 2008-08-07 19:10:47, 註解 無‧
hungjeff
一般會員


發表:10
回覆:9
積分:3
註冊:2007-02-22

發送簡訊給我
#3 引用回覆 回覆 發表時間:2008-08-08 10:26:55 IP:140.128.xxx.xxx 訂閱
謝謝careychen大大,那再請問一下,我想要用托曳的功能但是托過去只有縮圖是正確,沒有檔名,請大大再幫我看一下,謝謝
下列程式是listview1托曳到listview2的程式碼:
procedure TForm1.ListView2DragDrop(Sender, Source: TObject; X, Y: Integer);
var i: integer;
LV: TListView;
begin
LV := (Source as TListView);
for i:=0 to LV.Items.Count-1 do if LV.Items[i].Selected then ListView2.Items.AddItem(LV.Items[i]);
end;
procedure TForm1.ListView2DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
Accept := Source = ListView1;
end;
careychen
尊榮會員


發表:41
回覆:580
積分:959
註冊:2004-03-03

發送簡訊給我
#4 引用回覆 回覆 發表時間:2008-08-08 21:38:22 IP:59.126.xxx.xxx 訂閱
請改下列這樣
===================引 用 hungjeff 文 章===================
謝謝careychen大大,那再請問一下,我想要用托曳的功能但是托過去只有縮圖是正確,沒有檔名,請大大再幫我看一下,謝謝
下列程式是listview1托曳到listview2的程式碼:
procedure TForm1.ListView2DragDrop(Sender, Source: TObject; X, Y: Integer);
var i: integer;
LV: TListView;
begin
LV := (Source as TListView);
// i這樣會不行的原因是 Owner 不同
for i:=0 to LV.Items.Count-1 do if LV.Items[i].Selected then ListView2.Items.AddItem(LV.Items[i]);
for i:=0 to LV.Items.Count-1 do if LV.Items[i].Selected then (ListView2.Items.Add).Assign((LV.Items[i]));
end;
procedure TForm1.ListView2DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
Accept := Source = ListView1;
end;
------
價值的展現,來自於你用哪一個角度來看待它!!
編輯記錄
careychen 重新編輯於 2008-08-08 21:39:06, 註解 無‧
hungjeff
一般會員


發表:10
回覆:9
積分:3
註冊:2007-02-22

發送簡訊給我
#5 引用回覆 回覆 發表時間:2008-08-11 10:36:08 IP:140.128.xxx.xxx 訂閱
感謝大大的幫忙,我這個程式還是有很多bug,我再慢慢處理好了,想做一個類似無名小幫手的程式還真難><。
careychen
尊榮會員


發表:41
回覆:580
積分:959
註冊:2004-03-03

發送簡訊給我
#6 引用回覆 回覆 發表時間:2008-08-11 11:26:20 IP:218.210.xxx.xxx 訂閱
不會啦,互相幫忙~~

不過~~ 無名的小幫手還沒用過咧,等等來看看好了~~

===================引 用 hungjeff 文 章===================
感謝大大的幫忙,我這個程式還是有很多bug,我再慢慢處理好了,想做一個類似無名小幫手的程式還真難><。
------
價值的展現,來自於你用哪一個角度來看待它!!
hungjeff
一般會員


發表:10
回覆:9
積分:3
註冊:2007-02-22

發送簡訊給我
#7 引用回覆 回覆 發表時間:2008-08-11 11:36:34 IP:140.128.xxx.xxx 訂閱
如果大大看完之後有建議可以教導一下小弟,我完成這個程式會po上來大家瞧瞧地~
careychen
尊榮會員


發表:41
回覆:580
積分:959
註冊:2004-03-03

發送簡訊給我
#8 引用回覆 回覆 發表時間:2008-08-11 12:04:13 IP:218.210.xxx.xxx 訂閱
剛大概看了一下,一直出現一堆錯誤訊息,所以~~~ 
俺的建議是,要多測一下再上線

我剛用到快吐了,做一步,彈一次錯誤訊息,而且還是不一樣的,沒有 qa 人員嗎?

===================引 用 hungjeff 文 章===================
如果大大看完之後有建議可以教導一下小弟,我完成這個程式會po上來大家瞧瞧地~
------
價值的展現,來自於你用哪一個角度來看待它!!
hungjeff
一般會員


發表:10
回覆:9
積分:3
註冊:2007-02-22

發送簡訊給我
#9 引用回覆 回覆 發表時間:2008-08-11 12:32:54 IP:140.128.xxx.xxx 訂閱
大大你是說什麼程式出現錯誤訊息啊,無名上傳小幫手應該是不會有錯誤訊息吧@@
還是大大有興趣看一下我寫的程式。
careychen
尊榮會員


發表:41
回覆:580
積分:959
註冊:2004-03-03

發送簡訊給我
#10 引用回覆 回覆 發表時間:2008-08-11 14:32:49 IP:218.210.xxx.xxx 訂閱
後來我第二次打開,跑一跑只出現這個訊息,而這個出現的方式,是我去網上砍了我第一次產生的
的【未命名相簿】之後,再開程式所產生的
http://delphi.ktop.com.tw/download.php?download=upload/489fdbef49057_Error-1.JPG

我後來弄了一下,發現是我如果是第一次進無名小站,而且在使用確認信之後,就把上傳小幫手打開的話
一堆 Error 就出現了,可能他也發現了 Error,所以我第二次進入時,我發現我的上面多了一個【未命名相簿】
錯誤就減少了

===================引 用 hungjeff 文 章===================
大大你是說什麼程式出現錯誤訊息啊,無名上傳小幫手應該是不會有錯誤訊息吧@@
還是大大有興趣看一下我寫的程式。

你先寫一寫吧,寫完後再發表給大家看一看,讓我們學習學習
------
價值的展現,來自於你用哪一個角度來看待它!!
hungjeff
一般會員


發表:10
回覆:9
積分:3
註冊:2007-02-22

發送簡訊給我
#11 引用回覆 回覆 發表時間:2008-08-11 14:45:42 IP:140.128.xxx.xxx 訂閱
應該是你沒有設定一個相本,所以上傳的圖不知道放哪邊,會發生錯誤,而小幫手會幫你先建立個未命名相簿。
careychen
尊榮會員


發表:41
回覆:580
積分:959
註冊:2004-03-03

發送簡訊給我
#12 引用回覆 回覆 發表時間:2008-08-11 16:01:32 IP:218.210.xxx.xxx 訂閱
是沒錯,的確是這樣~~~ But ,對使用者來說,只是一陣錯諤~~~~,然後按下 X 而已

===================引 用 hungjeff 文 章===================
應該是你沒有設定一個相本,所以上傳的圖不知道放哪邊,會發生錯誤,而小幫手會幫你先建立個未命名相簿。
------
價值的展現,來自於你用哪一個角度來看待它!!
系統時間:2024-04-28 3:13:29
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!