  | 
				VFP 愛用者社區 本討論區為 Visual Foxpro 愛用者經驗交流的地方, 請多多利用"搜尋"的功能, 先查看看有無前例可循, 如果還有不懂的再發問. 部份主題有附加檔案, 須先註冊成為社區居民才可以下載.   
				 | 
			 
		 
		 
	
		| 上一篇主題 :: 下一篇主題   | 
	 
	
	
		| 發表人 | 
		內容 | 
	 
	
		jepp
 
 
  註冊時間: 2006-03-03 文章: 30
 
  第 1 樓
  | 
		
			
				 發表於: 星期四 五月 11, 2006 11:38 am    文章主題: 請問一個TreeView的問題 | 
				     | 
			 
			
				
  | 
			 
			
				假設產品關係:
 
                    A001 由 A002、A003 組成,
 
                           A002 由 A004、A005組成,
 
                           A003 由 A004、A006組成。
 
 
請問各位高手,
 
在TreeView中,A004只會秀第一個。A003內的A004該如何秀出來?
 
 
感恩~ | 
			 
		  | 
	 
	
		| 回頂端 | 
		 | 
	 
	
		  | 
	 
	
		garfield Site Admin
  
  註冊時間: 2003-01-30 文章: 2160
 
  第 2 樓
  | 
		
			
				 發表於: 星期四 五月 11, 2006 2:49 pm    文章主題:  | 
				     | 
			 
			
				
  | 
			 
			
				須要再描述清楚一點,
 
你是如何將資料填入TreeView中的. _________________ 利用>>搜尋<<的功能會比問的還要快得到答案. | 
			 
		  | 
	 
	
		| 回頂端 | 
		 | 
	 
	
		  | 
	 
	
		jepp
 
 
  註冊時間: 2006-03-03 文章: 30
 
  第 3 樓
  | 
		
			
				 發表於: 星期四 五月 11, 2006 7:19 pm    文章主題:  | 
				     | 
			 
			
				
  | 
			 
			
				我是參考 "玩轉TreeView" 。
 
假設tmp1內資料:
 
 
 
prno     prno1   
 
-----------------
 
A001
 
A002    A001
 
A003    A001
 
A004    A002
 
A005    A002
 
A004    A003
 
A006    A003
 
-----------------
 
執行以下程式碼後,所得到的結果會是:
 
A001-----子節點 A002和A003
 
A002-----子節點 A004和A005
 
A003-----子節點A006    (*A004不會秀出來)
 
************
 
sele tmp1
 
go top
 
SCAN
 
IF empty(tmp1.prno1)
 
   .Nodes.Add(,,ALLTRIM(prno),ALLTRIM(xprna))
 
ELSE
 
   .Nodes.Add(ALLTRIM(prno1),4,ALLTRIM(prno),ALLTRIM(xprna))
 
ENDIF
 
IF .not. empty(icon1)
 
   .Nodes(RECNO()).Image=val(icon1)
 
ENDIF
 
IF .not. empty(icon2)
 
   .Nodes(RECNO()).SelectedImage=val(icon2)
 
ENDIF
 
ENDSCAN	
 
--------------------------------------------------- | 
			 
		  | 
	 
	
		| 回頂端 | 
		 | 
	 
	
		  | 
	 
	
		garfield Site Admin
  
  註冊時間: 2003-01-30 文章: 2160
 
  第 4 樓
  | 
		
			
				 發表於: 星期五 五月 12, 2006 12:55 pm    文章主題:  | 
				     | 
			 
			
				
  | 
			 
			
				試看看
 
.Nodes.Add(ALLTRIM(prno1),4,ALLTRIM(prno),ALLTRIM(xprna)) 
 
改用
 
.Nodes.Add(ALLTRIM(prno1),4,ALLTRIM(str(recno())+'_',ALLTRIM(xprna)) _________________ 利用>>搜尋<<的功能會比問的還要快得到答案. | 
			 
		  | 
	 
	
		| 回頂端 | 
		 | 
	 
	
		  | 
	 
	
		jepp
 
 
  註冊時間: 2006-03-03 文章: 30
 
  第 5 樓
  | 
		
			
				 發表於: 星期六 五月 13, 2006 1:11 am    文章主題:  | 
				     | 
			 
			
				
  | 
			 
			
				感謝garfield大大指導。
 
我把程式調整為
 
with thisform.tree
 
sele tmp1
 
go top
 
xprno=prno
 
xrec=alltrim(str(recno(),9))
 
SCAN	
 
xprno1=prno1
 
xrec1=alltrim(str(recno(),9))
 
if xprno#xprno1		        
 
sele tmp1
 
Trec=recno()
 
set order to tmp11
 
seek xprno1
 
xrec=alltrim(str(recno(),9))
 
sele tmp1
 
go Trec
 
if .not. empty(tmp1.prno1)
 
xprno=prno1                         
 
else
 
xprno=prno
 
endif
 
endif
 
sele pro
 
seek tmp1.prno
 
stor '' to xprna
 
if ! eof()
 
xprna=prna     
 
endif
 
sele tmp1
 
IF empty(tmp1.prno1)
 
.Nodes.Add(,,'N'+xrec,ALLTRIM(xprna))
 
ELSE
 
.Nodes.Add('N'+xrec,4,'N'+xrec1,ALLTRIM(xprna))
 
ENDIF
 
.Nodes(recno()).Image=1
 
.Nodes(recno()).SelectedImage=2
 
ENDSCAN	
 
endwith
 
************
 
可全部秀出,可是
 
.Nodes(recno()).Image=1
 
.Nodes(recno()).SelectedImage=2
 
這兩行卻會出錯(原本寫法可秀出圖示),不知該怎麼改 ? | 
			 
		  | 
	 
	
		| 回頂端 | 
		 | 
	 
	
		  | 
	 
	
		garfield Site Admin
  
  註冊時間: 2003-01-30 文章: 2160
 
  第 6 樓
  | 
		
			
				 發表於: 星期日 五月 14, 2006 11:13 pm    文章主題:  | 
				     | 
			 
			
				
  | 
			 
			
				將 IF empty(tmp1.prno1) 
 
.Nodes.Add(,,'N'+xrec,ALLTRIM(xprna)) 
 
ELSE 
 
.Nodes.Add('N'+xrec,4,'N'+xrec1,ALLTRIM(xprna)) 
 
ENDIF 
 
.Nodes(recno()).Image=1 
 
.Nodes(recno()).SelectedImage=2 
 
改成
 
IF empty(tmp1.prno1) 
 
oNode = .Nodes.Add(,,'N'+xrec,ALLTRIM(xprna)) 
 
ELSE 
 
oNode = .Nodes.Add('N'+xrec,4,'N'+xrec1,ALLTRIM(xprna)) 
 
ENDIF 
 
oNode.Image=1 
 
oNode.SelectedImage=2 
 
因為目前的node 不一定等於 recno() _________________ 利用>>搜尋<<的功能會比問的還要快得到答案. | 
			 
		  | 
	 
	
		| 回頂端 | 
		 | 
	 
	
		  | 
	 
	
		jepp
 
 
  註冊時間: 2006-03-03 文章: 30
 
  第 7 樓
  | 
		
			
				 發表於: 星期二 五月 16, 2006 8:37 pm    文章主題:  | 
				     | 
			 
			
				
  | 
			 
			
				| 感謝~ 我再試試 | 
			 
		  | 
	 
	
		| 回頂端 | 
		 | 
	 
	
		  | 
	 
	
		 | 
	 
 
  
  	 
	    
  	   | 
 	
您 無法 在這個版面發表文章 您 無法 在這個版面回覆文章 您 無法 在這個版面編輯文章 您 無法 在這個版面刪除文章 您 無法 在這個版面進行投票 您 無法 在這個版面附加檔案 您 無法 在這個版面下載檔案
  | 
   
  
		 |