  | 
				VFP 愛用者社區 本討論區為 Visual Foxpro 愛用者經驗交流的地方, 請多多利用"搜尋"的功能, 先查看看有無前例可循, 如果還有不懂的再發問. 部份主題有附加檔案, 須先註冊成為社區居民才可以下載.   
				 | 
			 
		 
		 
	
		| 上一篇主題 :: 下一篇主題   | 
	 
	
	
		| 發表人 | 
		內容 | 
	 
	
		Ruey
 
 
  註冊時間: 2003-03-12 文章: 1698 來自: tunglo
  第 1 樓
  | 
		
			
				 發表於: 星期六 一月 17, 2004 11:14 am    文章主題: Grid與Combo的結合?(轉貼) | 
				     | 
			 
			
				
  | 
			 
			
				來源:紅狐 Jack許
 
http://fox.hanyu.com.tw/View.aspx?fbId=1&Id=11102
 
 
*如果設定錯誤,combo box 會顯示空白的
 
 
*
 
* 直接將本檔(Grid_Combo_.html);重新命名為:Grid_Combo_.prg  // DO IT
 
 
 Form1=  CreateObject("Form1")
 
 Form1.Show
 
 Read Events
 
*RELEASE ALL EXTENDED
 
*On Shutdown
 
*Clear ALL
 
*Quit
 
 RETURN
 
 
*====================
 
DEFINE CLASS Form1 AS form
 
Top = 0                                                                         
 
Left = 0                                                                        
 
Caption = "Form1"                                                               
 
Name = "Form1"                                                                  
 
                                                                                
 
*====================
 
ADD OBJECT grdDef AS grid WITH ;
 
ColumnCount = 4                                                                 ,;
 
Left = 24, Top = 24                                                             ,;
 
RecordSource = "abcCursor1"                                                     ,;
 
RecordSourceType = 1                                                            ,;
 
RowHeight = 23                                                                  ,;
 
Name = "grdDef"                                                                 ,;
 
Column1.ControlSource = ""                                                      ,;
 
Column1.Width = 62                                                              ,;
 
Column1.Name = "Column1"                                                        ,;
 
Column2.ControlSource = ""                                                      ,;
 
Column2.Width = 62                                                              ,;
 
Column2.Name = "Column2"                                                        ,;
 
Column3.ControlSource = ""                                                      ,;
 
Column3.Width = 62                                                              ,;
 
Column3.Name = "Column3"                                                        ,;
 
Column4.ControlSource = ""                                                      ,;
 
Column4.Width = 87                                                              ,;
 
Column4.Name = "Column4"
 
 
PROCEDURE grdDef.init
 
With THIS
 
     With .Column4
 
          .AddObject('Combo1','ComboBox')
 
          With .Combo1
 
               .BoundColumn = 2
 
               .ColumnCount = 2
 
 
               #DEFINE bCursorOrArray .F.
 
               #if bCursorOrArray
 
                  messagebox("Cursor")
 
                  .RowSourceType = 6
 
                  .RowSource = "abcCursor2.remark,num"
 
               #else
 
                  messagebox("Array")
 
                  .RowSourceType = 5
 
                  .RowSource = "aArray"
 
               #endif
 
 
               .Visible = .T.
 
          EndWith
 
          .ReadOnly = .F.
 
          .CurrentControl = "Combo1"
 
          .DynamicCurrentControl = "'Combo1'"
 
          .Sparse = .F.
 
     EndWith
 
 
     With .Column3
 
          .Sparse = .F.
 
          .Text1.ForeColor = RGB(0,0,255)
 
     EndWith
 
EndWith
 
 
 
ENDPROC
 
                                                                                
 
*[x]=================     
 
PROCEDURE Destroy         
 
          _Screen.Visible = .t.
 
          RELEASE THISFORM
 
          CLEAR EVENTS    
 
ENDPROC                   
 
 
*====================
 
PROCEDURE LOAD
 
 
create cursor abcCursor1 ( c1 c(10),c2 c(10),c3 c(10),c4 I)
 
Insert into abcCursor1 values( 'r1.c1','r1.c2','r1.c3',4)
 
Insert into abcCursor1 values( 'r2.c1','r2.c2','r2.c3',3)
 
Insert into abcCursor1 values( 'r3.c1','r3.c2','r3.c3',2)
 
Insert into abcCursor1 values( 'r4.c1','r4.c2','r4.c3',1)
 
goto top
 
 
create cursor abcCursor2 ( remark C(6),num I)
 
Insert into abcCursor2 values( '缺補中',1)
 
Insert into abcCursor2 values( '運送中',2)
 
Insert into abcCursor2 values( '已交貨',3)
 
Insert into abcCursor2 values( '失蹤中',4)
 
 
PUBLIC aArray[recCount('abcCursor2'),2]
 
COPY TO ARRAY aArray
 
 
ENDPROC
 
********************************
 
ENDDEFINE  && From Jack許       
 
********************* _________________ #############################
 
快樂媽咪系列幸福宅配,喝十全雞湯~原來幸福那麼簡單!!
 
 
學會VFP使用者社區的搜尋,Code才會更有趣~
 
############################# | 
			 
		  | 
	 
	
		| 回頂端 | 
		 | 
	 
	
		  | 
	 
	
		 | 
	 
 
  
  	 
	    
  	   | 
 	
您 無法 在這個版面發表文章 您 無法 在這個版面回覆文章 您 無法 在這個版面編輯文章 您 無法 在這個版面刪除文章 您 無法 在這個版面進行投票 您 無法 在這個版面附加檔案 您 無法 在這個版面下載檔案
  | 
   
  
		 |