VFP 愛用者社區 首頁 VFP 愛用者社區
本討論區為 Visual Foxpro 愛用者經驗交流的地方, 請多多利用"搜尋"的功能, 先查看看有無前例可循, 如果還有不懂的再發問. 部份主題有附加檔案, 須先註冊成為社區居民才可以下載.
 
 常見問題常見問題   搜尋搜尋   會員列表會員列表   會員群組會員群組   會員註冊會員註冊 
 個人資料個人資料   登入檢查您的私人訊息登入檢查您的私人訊息   登入登入

[翻譯] Chm For VFP9 Beta Release
前往頁面 上一頁  1, 2, 3 ... 12, 13, 14
 
發表新主題   回覆主題    VFP 愛用者社區 首頁 -> VFP 討論區
上一篇主題 :: 下一篇主題  
發表人 內容
朱育興



註冊時間: 2003-08-25
文章: 661
來自: 台中市大里區

第 196 樓

發表發表於: 星期六 一月 15, 2005 12:01 am    文章主題: 引言回覆

如何:為列示方塊或下拉式列示方塊選定資料來源型態


當要將項目或值填入列示方塊控制項和下拉式列示方塊控制項時,請設定控制項的 RowSource 屬性指定選項或值的來源來填滿控制項以及設定 RowSourceType 屬性確定如陣列或資料表格的來源型態。

提示:
在設定 RowSource 屬性決定要使用的來源之前,一般建議是先設定 RowSourceType 屬性。為確保控制項顯示最新的選項或值,請在 Init 事件中使用 Requery 方法程序,例如:This.Requery()。

注意:
當您要在程式碼中設定 RowSource 屬性時,必須將值放在雙引號 ("") 之中。

當 ColumnCount 屬性設定為 0 或 1 時,控制項在單欄中僅顯示第一個選項或值。反之,控制項要在欄中顯示每一個選項或值時,透過 ColumnCount 屬性設定最大欄數。您也可能需要設定 ColumnWidths 屬性來增長控制項的寬度,以便正確地將選項或值顯示在控制項中。

本主題包含根據所選定值來源的不同展示設定 RowSourceType 屬性和 RowSource 屬性之方法的範例。以下列出包含與來源型態可用的連結:

•無來源型態
•值來源型態
•別名來源型態
•SQL 命令敘述來源型態
•查詢來源型態
•陣列來源型態
•欄位來源型態
•檔案來源型態
•欄位結構來源型態
•下拉突顯式功能表來源型態
•集合來源型態
•不同的來源型態

有關您可以指定的來源型態和 ColumnCount 屬性對每個來源型態如何影響控制項的填入之詳細內容,請參閱「RowSourceType 屬性」和「RowSource 屬性」。

相關詳細資訊,Visual FoxPro 提供下列使用 RowSourceType 屬性和 RowSource 屬性的範例:

•在下拉式列示方塊中加入新選項的範例
•允許使用者選取列示方塊值的範例
•在列示方塊之間移動選項的範例
•以交談模式開啟多個檔案的範例



無來源型態

您可以不指定一個來源或來源型態來填滿列示方塊或下拉式列示方塊。


若要不指定一個來源填滿控制項

1.將 RowSourceType 屬性設定為 0 (無)。

無是預設設定值以及無法利用與資料來源結合並自動設定控制項的選項。

2.使用 AddItem 方法程序、AddListItem 方法程序、List 屬性或 ListItem 屬性將值或選項加入到控制項中。


例如,下列各行程式碼將 RowSourceType 屬性設定為 0 表示無來源型態以及使用 AddItem 方法程序在 frmForm1 表單的 lstMyListBox 列示方塊中加入三個選項:

frmForm1.lstMyListBox.RowSourceType = 0
frmForm1.lstMyListBox.AddItem("第一個選項")
frmForm1.lstMyListBox.AddItem("第二個選項")
frmForm1.lstMyListBox.AddItem("第三個選項")

列示方塊顯示選項:"第一個選項"、"第二個選項" 和 "第三個選項"。相關詳細資訊請參閱「AddItem 方法程序 (Visual FoxPro)」、「AddListItem 方法程序」、「List 屬性」和「ListItem 屬性」。

若要從清單中移除選項,請使用 RemoveItem 方法程序。例如,下面一行程式碼會從列示方塊中移除第二個選項 ("第二個選項"):

frmForm1.lstMyListBox.RemoveItem(2)

相關詳細資訊請參閱「RemoveItem 方法程序」。



值來源型態

您可以使用個別資料值的清單填滿列示方塊或下拉式列示方塊。


若要使用個別資料值的清單填滿控制項

1.將 RowSourceType 屬性設定為 1 (值)。

2.指定用逗號分隔資料值的清單來設定 RowSource 屬性,在資料值與逗號之間不能有空格。


例如,下面各行程式碼將 RowSourceType 屬性設定為 1 表示來源是一個用逗號分隔資料值的清單,而且在 RowSource 屬性中在雙引號 ("") 之中指定用逗號分隔的清單:

Form1.lstMyList.RowSourceType = 1
Form1.lstMyList.RowSource = "一,二,三,四"



別名來源型態

您可以使用在開啟資料表格所指定資料表格別名的一個或多個欄位的資料值來填滿列示方塊或下拉式列示方塊。


若要使用資料表格別名的一個或多個欄位值填滿控制項

1.將 RowSourceType 屬性設定為 2 (資料表格的別名)。

2.指定資料表格別名來設定 RowSource 屬性。


例如,下列各行程式碼將 RowSourcetype 屬性設定為 2 表示來源是一個由標示 Customers 資料表格別名的資料表格,而且在 RowSource 屬性中指定 "Customers" 這樣的資料表格別名:

提示:
首先必須確認在程式碼執行前,該資料表格已開啟。

OPEN DATABASE (HOME(2)+"Northwind\Northwind")
Form1.lstMyList.RowSourceType = 2
Form1.lstMyList.RowSource = "Customers"

ColumnCount 屬性決定用於滿控制項的資料值之欄位數目。當 ColumnCount 屬性設定為 0 或 1 時,控制項會顯示資料表格中第一個欄位的資料值。當 ColumnCount 屬性設定為大於 1 時,控制項會顯示資料表格中由 ColumnCount 屬性指定數目的欄位之資料值。例如,如果 ColumnCount 屬性設定為 3 時,控制項會顯示資料表格中最前面三個欄位的資料值。

注意:
當 RowSourceType 屬性是 2 (資料表格的別名) 或 6 (欄位) 時,資料表格的資料記錄指標將移動到使用者所選定的記錄。



SQL 命令敘述來源型態

您可以使用由諸如 SQL SELECT 的 SQL 命令敘述所建立的暫存資料表格或資料表格的值來填滿列示方塊或下拉式列示方塊。


若要使用來自 SQL 命令敘述的資料值填滿控制項

1.將 RowSourceType 屬性設定為 3 (SQL 命令敘述)。

2.指定 SQL SELECT 敘述來設定 RowSource 屬性。


提示:
預設情況下,不帶 INTO 引數的 SQL SELECT 敘述立刻會出現 [瀏覽] 視窗並顯示得出的暫存資料表格的資料。相關詳細資訊請參閱「[瀏覽] 視窗」。建議應在 SQL SELECT 敘述中包含 INTO CURSOR 子句來避免顯示 [瀏覽] 視窗。

例如,下列各行程式碼將 RowSourcetype 屬性設定為 3 表示來源是一個由 SQL 敘述所建立的暫存資料表格或資料表格,而且在 RowSource 屬性中指定一個 SQL SELECT 敘述,其是由位於 ..\Samples\Northwind 目錄中的 Northwind 資料庫範例中的 Customers 資料表格的全部欄位和記錄選定到 myCursor 暫存資料表格中:

OPEN DATABASE (HOME(2)+"Northwind\Northwind")
Form1.lstMyList.RowSourceType = 3
Form1.lstMyList.RowSource = "SELECT * FROM Customers INTO CURSOR myCursor"

有關 SQL SELECT 敘述的詳細內容,請參閱「SELECT - SQL 命令」。



查詢來源型態

您可以使用由 [查詢設計工具] 所建立的查詢和儲存在查詢檔案 (.qpr) 中的查詢之結果來填滿列示方塊或下拉式列示方塊。有關查詢的詳細內容,請參閱「查詢與資料集設計工具」和「如何:建立查詢 (Visual FoxPro)」。


若要使用來自一個查詢的資料值填滿控制項

1.將 RowSourceType 屬性設定為 4 (查詢檔)。

2.指定 .qpr 檔案的名稱 (如果需要,請包含路徑) 來設定 RowSource 屬性。

注意:
必須確認有包含 .qpr 檔案副檔名。如果不指定檔案副檔名,Visual FoxPro 的預設檔案副檔名是 .qpr。


例如,下列各行程式碼將 RowSourcetype 屬性設定為 4 表示來源是一個 .qpr 檔案,而且在 RowSource 屬性中指定 .qpr 檔案的名稱:

Form1.lstMyList.RowSourceType = 4
Form1.lstMyList.RowSource = "MyQuery.qpr"



陣列來源型態

您可以使用儲存在陣列中的資料或值來填滿列示方塊或下拉式列示方塊。您可以為 RowSource 建立應用程式中其他部份建立的陣列,或者建立一個表單或表單集的陣列屬性。有關陣列的詳細內容,請參閱「陣列」。有關建立陣列屬性的詳細內容,請參閱「建立表單」。

若要使用陣列填滿控制項

1.將 RowSourceType 屬性設定為 5 (陣列)。

2.指定陣列的名稱來設定 RowSource 屬性。


例如,下列各行程式碼將建立有 10 個元素的陣列,在陣列中儲存資料值,RowSourcetype 屬性設定為 5 表示來源是一個陣列,而且在 RowSource 屬性中指定該陣列的名稱:

DIMENSION gaMyArray(10)
FOR gnCount = 1 to 10
STORE gnCount TO gaMyArray(gnCount)
NEXT
Form1.lstMyList.RowSourceType = 5
Form1.lstMyList.RowSource = "gaMyArray"

注意:
Visual FoxPro 在應用程式中只在需要的時候使用 RowSource 屬性的設定值,而不是在設定 RowSource 屬性的方法程序中使用,因此需要特別注意作用範圍。

例如,如果在方法程序中建立了一個區域性陣列,則這個陣列的作用範圍只在這個方法程序內,並不是每當 Visual FoxPro 使用該陣列時,都可用。如果將 RowSource 屬性設定為表單或表單層級的陣列屬性,則需要相對於控制項參考這個屬性,而不應相對於設定屬性的方法程序。例如,假設有一個名為 arrayprop 的表單層級的陣列屬性,以及表單的 Init 事件中的下面兩行程式碼。第一行程式碼會產生錯誤而第二行程式碼不會:

THIS.lst1.RowSource = "THIS.arrayprop"
THIS.lst1.RowSource = "THISFORM.arrayprop"



欄位來源型態

您可以使用單一資料表格中欄位值來填滿列示方塊或下拉式列示方塊。不同於 RowSourceType 屬性設定為 2 (資料表格的別名),RowSourceType 屬性設定為 6 (欄位) 可以不按欄位在資料表格中的實際位置來顯示該欄位。

提示:
如果想使用多個資料表格的欄位來填滿控制項,需將 RowSourceType 屬性設定為 3,且 RowSource 屬性指定一個 SQL SELECT 敘述。


若要使用來自一個單一資料表格的欄位填滿控制項

1.將 RowSourceType 屬性設定為 6 (欄位)。

2.指定一個欄位或用逗號分隔的一系列欄位值來設定 RowSource 屬性。

如果資料表格已開啟,可以在下列方法中設定 RowSource 屬性:

Form1.lstMyList.RowSource = 欄位1
Form1.lstMyList.RowSource = 欄位2, 欄位3, ...

如果資料表格未開啟,在欄位或一系列的欄位前面加上資料表格別名和句點 (.)。

Form1.lstMyList.RowSource = 資料表格別名.欄位1
Form1.lstMyList.RowSource = 資料表格別名.欄位1, 欄位3, 欄位2, ...


例如,下列各行程式碼將 RowSourcetype 屬性設定為 6 表示來源型態是一個欄位,而且在 RowSource 屬性中指定位於 ..\Samples\Northwind 目錄中的 Northwind 資料庫中的 Products 資料表格的欄位:

OPEN DATABASE (HOME(2)+"Northwind\Northwind")
USE Products
Form1.lstMyList.RowSourceType = 6
Form1.lstMyList.RowSource = "productname, productid"

下列各行程式碼在 RowSource 屬性中指定 Customers 資料表格 (未開啟) 的欄位:

OPEN DATABASE (HOME(2)+"Northwind\Northwind")
Form1.lstMyList.RowSourceType = 6
Form1.lstMyList.RowSource = "Customers.companyname, customerid"



檔案來源型態

您可以使用目前所在目錄下的檔案名稱來填滿列示方塊或下拉式列示方塊。列示方塊中的選項也可含有選定不同的磁碟機和目錄,並在列示方塊中顯示其中的檔案名稱。


若要使用來自目錄中的檔案名稱填滿控制項

1.將 RowSourceType 屬性設定為 7 (檔案)。

2.指定一個檔案名稱格式或遮罩 (例如,*.* 或 *.檔案副檔名) 來設定 RowSource 屬性。


例如,下列各行程式碼將 RowSourcetype 屬性設定為 7 表示來源型態是一個檔案,而且在 RowSource 屬性中指定為檔案名稱格式:

Form1.lstMyList.RowSourceType = 7
Form1.lstMyList.RowSource = "*.*"



欄位結構來源型態

您可以使用資料表格中的欄位名稱來填滿列示方塊或下拉式列示方塊。當使用者要在特定欄位搜尋資料或在資料表格中組織那些欄位時,顯示一系列的欄位名稱就很有用。


若要使用來自一個資料表格的欄位名稱填滿控制項

1.將 RowSourceType 屬性設定為 8 (欄位結構)。

2.指定一個資料表格的名稱或別名來設定 RowSource 屬性。


例如,下列各行程式碼將 RowSourcetype 屬性設定為 8 表示來源型態是一個資料表格的欄位結構,而且在 RowSource 屬性中指定該資料表格的名稱:

Form1.lstMyList.RowSourceType = 8
Form1.lstMyList.RowSource = "Customers"



下拉突顯式功能表來源型態

包含這一選項是為了提供向後回朔之相容性。將 RowSourceType 屬性設定為 9 (下拉突顯式功能表),則可以用一個先前定義的下拉突顯式功能表或功能表來填滿列示方塊或下拉式列示方塊。


若要使用下拉突顯式功能表填滿控制項

•將 RowSourceType 屬性設定為 9 (下拉突顯式功能表)。



集合來源型態

您可以使用在一個集合或集合物件中的成員或物件的屬性值來填滿列示方塊或下拉式列示方塊。


若要使用集合的成員填滿控制項

1.將 RowSourceType 屬性設定為 10 (集合)。

2.指定一個集合的名稱來設定 RowSource 屬性。


例如,下列各行程式碼將建立一個集合和兩個表單,在集合中加入表單和三個字串,RowSourcetype 屬性設定為 10 表示來源型態是一個集合物件,而且在 RowSource 屬性中指定該集合中的集合名稱和物件屬性:

colMyCollection=CREATEOBJECT("Collection")
frm1=CREATEOBJECT("Form")
frm2=CREATEOBJECT("Form")
colMyCollection.Add(frm1)
colMyCollection.Add(frm2)
colMyCollection.Add("Item 1")
colMyCollection.Add("Item 2")
colMyCollection.Add("Item 3")
Form1.lstMyList.RowSourceType = 10
Form1.lstMyList.RowSource = "colMyCollection, Caption, Name"



不同的來源型態

您可以使用從不同來源的項目或值來填滿列示方塊或下拉式列示方塊。


若要使用不同來源填滿控制項

•請參閱「使用不同來源的值填滿列示方塊之範例」。



相關資訊

用以顯示清單的控制項

在早期版本中建立的控制項和物件




----------------------------------------------------------------------------------------------
原文:


How to: Choose the Type of Data for a List or Combo Box


When you want to populate a ListBox or ComboBox control with items or values, set the control's RowSource property to specify the source of items or values to fill the control and set the RowSourceType property to identify the source type, such as an array or table.

Tip:
It is recommended that you set the RowSourceType property before setting RowSource to determine the source that can be used. To ensure that the control displays the most recent items or values, use the Requery method in the Init method, for example, This.Requery().

Note:
When you set the RowSource property in code, you must enclose the value with quotation marks ("").

When the ColumnCount property is set to 0 or 1, the control displays the first item or value only in a single column. Otherwise, the control displays each item or value in a column up to the number of columns specified by ColumnCount. You might also need to set the ColumnWidths property to expand the width of the control so the items or values within display properly.

This topic contains examples that illustrate ways you can set RowSourceType and RowSource depending on the source of values you choose. The following list contains links to the source types available:

•No Source Type
•Value Source Type
•Alias Source Type
•SQL Statement Source Type
•Query Source Type
•Array Source Type
•Fields Source Type
•Files Source Type
•Field Structure Source Type
•Pop-Up Source Type
•Collection Source Type
•Different Source Types

For details about source types, the sources you can specify, and how ColumnCount affects population of the control for each source type, see RowSourceType Property and RowSource Property.

For more information, Visual FoxPro provides the following samples that use the RowSourceType and RowSource properties:

•Add New Items to a Combo Box Sample
•Allow Users to Choose List Values Sample
•Move Items Between List Boxes Sample
•Open Multiple Files Interactively Sample



No Source Type

You can populate a list box or combo box without specifying a source or source type.


To populate the control without specifying a source

1.Set RowSourceType to 0 (None).

None is the default setting and does not populate the control automatically.

2.Use the AddItem method, AddListItem method, List property, or ListItem property to add values or items to the control.


For example, the following lines of code set RowSourceType to 0 to indicate no source type and uses the AddItem method to add three items to the list box lstMyListBox on the form frmForm1:

frmForm1.lstMyListBox.RowSourceType = 0
frmForm1.lstMyListBox.AddItem("First Item")
frmForm1.lstMyListBox.AddItem("Second Item")
frmForm1.lstMyListBox.AddItem("Third Item")

The list box displays the items, "First Item", "Second Item", and "Third Item". For more information, see AddItem Method (Visual FoxPro), AddListItem Method, List Property, and ListItem Property.

To remove items from the list, use the RemoveItem method. For example, the following line of code removes the second item, "Second Item", from the list box:

frmForm1.lstMyListBox.RemoveItem(2)

For more information, see RemoveItem Method.



Value Source Type

You can populate a list box or combo box with a list of individual values.


To populate the control with a list of individual values

1.Set RowSourceType to 1 (Value).

2.Set RowSource by specifying the values in a comma-delimited list, using no spaces between the values and the commas.


For example, the following lines of code set RowSourceType to 1 to indicate that the source is a comma-delimited list of values and specifies a comma-delimited list in quotation marks ("") for RowSource:

Form1.lstMyList.RowSourceType = 1
Form1.lstMyList.RowSource = "one,two,three,four"



Alias Source Type

You can populate a list box or combo box with values from one or more fields in an open table by specifying the table's alias.


To populate the control with values from one or more fields using a table alias

1.Set RowSourceType to 2 (Table alias).

2.Set RowSource by specifying a table alias.


For example, the following lines of code set RowSourcetype to 2 to indicate that the source is a table identified by the table alias, Customers, and specifies "Customers" as the table alias for RowSource:

Tip:
Make sure the table is opened first before the code executes.

OPEN DATABASE (HOME(2)+"Northwind\Northwind")
Form1.lstMyList.RowSourceType = 2
Form1.lstMyList.RowSource = "Customers"

The ColumnCount property determines the number of fields from which values are used to populate the control. When ColumnCount set to 0 or 1, the control displays values from the first field in the table. When ColumnCount set to a value greater than 1, the control displays values from fields in the table up to the number specified by ColumnCount. For example, if ColumnCount is set to 3, the control displays values from the first three fields in the table.

Note:
When RowSourceType is 2 (Table alias) or 6 (Fields), the table record pointer moves to the record containing the value that the user chooses in the list.



SQL Statement Source Type

You can populate a list box or combo box with values a cursor or table created by a SQL statement, such as SQL SELECT.


To populate the control with values from a SQL statement

1.Set RowSourceType to 3 (SQL statement).

2.Set RowSource by specifying a SQL SELECT statement.


Tip:
By default in Visual FoxPro, SQL SELECT statements without INTO clauses display the resulting cursor immediately in a browse window. For more information, see Browse Window. It is suggested that you include an INTO CURSOR clause in your SQL SELECT statement to avoid displaying the browse window.

For example, the following lines of code set RowSourceType to 3 to indicate that the source is a cursor or table created from a SQL statement and specifies a SQL SELECT statement for RowSource that selects all fields and all records from the Customers table, located in the sample Northwind database in the directory, ..\Samples\Northwind, into a cursor named myCursor:

OPEN DATABASE (HOME(2)+"Northwind\Northwind")
Form1.lstMyList.RowSourceType = 3
Form1.lstMyList.RowSource = "SELECT * FROM Customers INTO CURSOR myCursor"

For more information about SQL SELECT statements, see SELECT - SQL Command.



Query Source Type

You can populate a list box or combo box with results from a query that you created using the Query Designer and saved in a query (.qpr) file. For more information about queries, see Query and View Designers and How to: Create Queries (Visual FoxPro).


To populate the control with values from a query

1.Set RowSourceType to 4 (Query file).

2.Set RowSource by specifying the name of a .qpr file, including a path if needed.

Note:
Make sure to include the .qpr file name extension. However, if you do not specify a file extension, Visual FoxPro assumes the file extension is .qpr.


For example, the following lines of code set RowSourceType to 4 to indicate that the source is a .qpr file and specifies the name of a .qpr file for RowSource:

Form1.lstMyList.RowSourceType = 4
Form1.lstMyList.RowSource = "MyQuery.qpr"



Array Source Type

You can populate a list box or combo box with items or values stored in an array. You use an array created elsewhere in your application or create an array property of the form or form set to specify for RowSource. For more information about arrays, see Arrays. For more information about creating array properties, see Creating Forms.


To populate the control from an array

1.Set RowSourceType to 5 (Array).

2.Set RowSource by specifying the name of the array.


For example, the following lines of code create an array with 10 elements, store values in the array, set RowSourceType to 5 to indicate the source is an array, and specifies the name of the array for RowSource:

DIMENSION gaMyArray(10)
FOR gnCount = 1 to 10
STORE gnCount TO gaMyArray(gnCount)
NEXT
Form1.lstMyList.RowSourceType = 5
Form1.lstMyList.RowSource = "gaMyArray"

Note:
The RowSource setting is evaluated by Visual FoxPro as needed in your application and is not confined only to the method in which you set RowSource. You need to keep this scope in mind.

For example, if you create a local array in a method, that array is scoped to the method and will not be available in all cases when Visual FoxPro needs to evaluate the property setting. If you set the RowSource to an array property of a form or form set, you need to reference the property relative to the control, not relative to the method in which you set the property. As an example, suppose you have a form array property named arrayProp and the following lines of code in the form's Init event. The first line of code produces an error while the second line does not:

THIS.lst1.RowSource = "THIS.arrayprop"
THIS.lst1.RowSource = "THISFORM.arrayprop"



Fields Source Type

You can populate a list box or combo box with values from fields from a single table. Unlike when RowSourceType is set to 2 (Table alias), setting RowSourceType to 6 (Fields) makes it possible to display fields independent of their actual positions in the table.

Tip:
If you want to populate the control with fields from multiple tables, set RowSourceType to 3 and specify a SQL SELECT statement for RowSource.


To populate the control from fields from a single table

1.Set RowSourceType to 6 (Fields).

2.Set RowSource by specifying a field or a comma-delimited list of fields.

If the table is open, you can specify RowSource in the following ways:

Form1.lstMyList.RowSource = field1
Form1.lstMyList.RowSource = field2, field3, ...

If the table is not open, precede the field or list of fields with a table alias and a period (.), for example:

Form1.lstMyList.RowSource = TableAlias.field1
Form1.lstMyList.RowSource = TableAlias.field1, field3, field2, ...


For example, the following lines of code open a table, set RowSourceType to 6 to indicate that the source type is fields, and specify fields from the Products table in the Northwind database, located in the directory ..\Samples\Northwind, for RowSource:

OPEN DATABASE (HOME(2)+"Northwind\Northwind")
USE Products
Form1.lstMyList.RowSourceType = 6
Form1.lstMyList.RowSource = "productname, productid"

The following lines of code specify fields from the Customers table, which is not open, for RowSource:

OPEN DATABASE (HOME(2)+"Northwind\Northwind")
Form1.lstMyList.RowSourceType = 6
Form1.lstMyList.RowSource = "Customers.companyname, customerid"



Files Source Type

You can populate a list box or combo box with the names of files from the current directory. The list also contains options for you to choose a different drive and directory to display file names from.


To populate the control with file names from a directory

1.Set RowSourceType to 7 (Files).

2.Set RowSource by specifying a file skeleton or mask, such as *.* or *.fileExt.

For example, the following lines of code set RowSourceType to 7 to indicate that the source type is files and specifies a file skeleton for RowSource:

Form1.lstMyList.RowSourceType = 7
Form1.lstMyList.RowSource = "*.*"



Field Structure Source Type

You can populate a list box or combo box with the names of fields in a table. Displaying a list of field names is useful when the user wants to search a particular field for values or to organize those fields in the table.


To populate the control with field names from a table

1.Set RowSourceType to 8 (Field structure).

2.Set RowSource by specifying a table name or table alias.


For example, the following lines of code set RowSourceType to 8 to indicate that the source type is a field structure of a table and specifies a table name for RowSource:

Form1.lstMyList.RowSourceType = 8
Form1.lstMyList.RowSource = "Customers"



Pop-Up Source Type

Included for backward compatibility, RowSourceType set to 9 (Pop-up) made it possible to populate a list box or combo box from a previously defined pop-up or menu.


To populate the control with a pop-up menu

•Set RowSourceType to 9 (Pop-up).



Collection Source Type

You can populate a list box or combo box with members and property values of objects in a collection, or Collection object.


To populate the control with collection members

1.Set RowSourceType to 10 (Collection).

2.Set RowSource by specifying the name of a collection.


For example, the following lines of code create a collection and two forms, adds the forms and three strings to the collection, sets RowSourceType to 10 to indicate that source type is a Collection object, and specifies the collection name and properties of objects in the collection for RowSource:

colMyCollection=CREATEOBJECT("Collection")
frm1=CREATEOBJECT("Form")
frm2=CREATEOBJECT("Form")
colMyCollection.Add(frm1)
colMyCollection.Add(frm2)
colMyCollection.Add("Item 1")
colMyCollection.Add("Item 2")
colMyCollection.Add("Item 3")
Form1.lstMyList.RowSourceType = 10
Form1.lstMyList.RowSource = "colMyCollection, Caption, Name"



Different Source Types

You can populate a list box or combo box with items and values from different sources.


To populate a control from different sources

•See Fill a List with Values from Different Sources Sample.



See Also

Controls for Displaying Lists

Controls and Objects Created in Earlier Versions

_________________
希望有更多人來參與
VFP wiki - 需要大家一起完成的VFP電子書與FAQ
回頂端
檢視會員個人資料 發送私人訊息 發送電子郵件 MSN Messenger
朱育興



註冊時間: 2003-08-25
文章: 661
來自: 台中市大里區

第 197 樓

發表發表於: 星期六 一月 15, 2005 10:50 pm    文章主題: 引言回覆

如何:建立具有多行的列示方塊


雖然列示方塊預設為一行,但 Visual FoxPro 中的列示方塊可以包含任意行。多行列示方塊和多筆編輯控制項的區別在於,在多行列示方塊中您一次選定一列,而在多筆編輯控制項中一次只可以選定一格,另外在多行列示方塊中,無法直接編輯列示方塊中的資料。



若要在列示方塊中顯示多行

1.將 ColumnCount 屬性設定為所需的行數。

2.設定 ColumnWidths 屬性。例如,如果列示方塊中有三行,下面的命令將各行寬度分別設定為 10、15 和 30。

THISFORM.listbox.ColumnWidths = "10, 15, 30"

3.將 RowSourceType 屬性設定為 6 - 欄位。

4.將 RowSource 屬性設定成列中顯示的欄位。

注意:
要想使行排列整齊,需要設定 ColumnWidths 屬性或將 FontName 屬性更改為等寬字型。列示方塊和下拉式列示方塊的 FirstElement 屬性是不影響多行清單。


當列示方塊的 RowSourceType 屬性設定為 0 - 無的時候,您可以使用 AddListItem 方法程序在多行列示方塊中新增項目。例如,下面的程式碼向一個列示方塊的指定欄位中新增文字︰

THISFORM.lst1.ColumnCount = 3
THISFORM.lst1.Columnwidths = "100,100,100"
THISFORM.lst1.AddListItem("列1 行1", 1,1)
THISFORM.lst1.AddListItem("列1 行2", 1,2)
THISFORM.lst1.AddListItem("列1 行3", 1,3)
THISFORM.lst1.AddListItem("列2 行2", 2,2)



相關資訊

用以顯示清單的控制項

使用控制項

在早期版本中建立的控制項和物件




----------------------------------------------------------------------------------------------
原文:


How to: Create Multicolumn List Boxes


Although the default number of columns in a list box is one, a list box in Visual FoxPro can contain as many columns as you want. A multicolumn list box differs from a grid in that you select a row at a time in a multicolumn list box while you can select individual cells in a grid, and data in the list cannot be directly edited.



To display multiple columns in a list box

1.Set the ColumnCount property to the number of desired columns.

2.Set the ColumnWidths Property. For example, if there are three columns in the list box, the following command would set the column widths to 10, 15, and 30, respectively:

THISFORM.listbox.ColumnWidths = "10, 15, 30"

3.Set the RowSourceType Property to 6 - Fields.

4.Set the RowSource Property to the fields to be displayed in the columns.

Note:
For the columns to align correctly, you need to either set the ColumnWidths property or change the FontName Property to a monospaced font. The FirstElement Property of ListBoxes and ComboBoxes is not effective in multi-column lists.


When the RowSourceType of the list is set to 0 - None, you can use the AddListItem method to add items to a multicolumn list box. For example, the following code adds text to specific columns in a list box:

THISFORM.lst1.ColumnCount = 3
THISFORM.lst1.Columnwidths = "100,100,100"
THISFORM.lst1.AddListItem("row1 col1", 1,1)
THISFORM.lst1.AddListItem("row1 col2", 1,2)
THISFORM.lst1.AddListItem("row1 col3", 1,3)
THISFORM.lst1.AddListItem("row2 col2", 2,2)



See Also

Controls for Displaying Lists

Using Controls

Controls and Objects Created in Earlier Versions

_________________
希望有更多人來參與
VFP wiki - 需要大家一起完成的VFP電子書與FAQ
回頂端
檢視會員個人資料 發送私人訊息 發送電子郵件 MSN Messenger
朱育興



註冊時間: 2003-08-25
文章: 661
來自: 台中市大里區

第 198 樓

發表發表於: 星期日 一月 16, 2005 11:14 pm    文章主題: 引言回覆

如何:允許使用者選定列示方塊中的多個列示方塊項目


預設情況下,一次只能選取一個列示方塊項目,但您也可以讓使用者選定列示方塊中的多個列示方塊項目。



若要選定列示方塊中的多個項目

•將列示方塊的 MultiSelect 屬性設定為真 (.T.)。

為了處理已選取的項目,例如把它們複製到一個陣列或在應用程式的其他地方使用它們,可以迴圈各列示方塊項目,處理 Selected 屬性為真 (.T.) 的項目。下面的程式碼寫在列示方塊的 InteractiveChange 事件中,並在名為 cboSelected 的下拉式列示方塊中顯示這個列示方塊中的已選取項目 ,並且在名為 txtNoSelected 文字輸入方塊中顯示已選取項的數目:

nNumberSelected = 0 && 追蹤數目的變數
THISFORM.cboSelected.Clear && 清除下拉式列示方塊
FOR nCnt = 1 TO THIS.ListCount
IF THIS.Selected(nCnt)
nNumberSelected = nNumberSelected + 1
THISFORM.cboSelected.Additem (THIS.List(nCnt))
ENDIF
ENDFOR
THISFORM.txtNoSelected.Value = nNumberSelected



相關資訊

用以顯示清單的控制項

使用控制項

在早期版本中建立的控制項和物件




----------------------------------------------------------------------------------------------
原文:


How to: Allow Users to Select Multiple Items in a List Box


The default behavior of a list allows one item at a time to be selected. You can, however, make it possible for a user to select multiple items in a list.



To allow multiple selected items in a list

•Set the MultiSelect property of the list to true (.T.).

To process the selected items — to copy them to an array or incorporate them elsewhere in your application — loop through the list items and process those for which the Selected Property is true (.T.). The following code could be included in the InteractiveChange Event of a list box to display the selected items in a combo box, cboSelected, and the number of selected items in a text box, txtNoSelected:

nNumberSelected = 0 && a variable to track the number
THISFORM.cboSelected.Clear && clear the combo box
FOR nCnt = 1 TO THIS.ListCount
IF THIS.Selected(nCnt)
nNumberSelected = nNumberSelected + 1
THISFORM.cboSelected.Additem (THIS.List(nCnt))
ENDIF
ENDFOR
THISFORM.txtNoSelected.Value = nNumberSelected



See Also

Controls for Displaying Lists

Using Controls

Controls and Objects Created in Earlier Versions

_________________
希望有更多人來參與
VFP wiki - 需要大家一起完成的VFP電子書與FAQ
回頂端
檢視會員個人資料 發送私人訊息 發送電子郵件 MSN Messenger
朱育興



註冊時間: 2003-08-25
文章: 661
來自: 台中市大里區

第 199 樓

發表發表於: 星期二 一月 18, 2005 12:57 am    文章主題: 引言回覆

如何:允許使用者在列示方塊中新增項目 


您可以讓使用者以交談模式在列示方塊新增項目。



若要讓使用者可以以交談模式在列示方塊新增項目

•請使用 AddItem 方法程序。

在下面範例中,當使用者按 ENTER 鍵時,利用程式在文字輸入方塊的 KeyPress 事件中,將文字輸入方塊中的文字新增到一個列示方塊中,並且清除文字輸入方塊中的文字:

LPARAMETERS nKeyCode, nShiftAltCtrl
IF nKeyCode = 13  && Enter 鍵
  THISFORM.lstAdd.AddItem(This.Value)
  THIS.Value = ""
ENDIF

您可以讓使用者從列示方塊輸入資料到資料表格中。如果列示方塊的 ControlSource 屬性設定為欄位,那麼使用者在列示方塊中選定的項目將會寫到資料表格中。這是保持資料表格中資料完整性的一個簡單方法。因為,這樣做使用者可能輸入錯誤資料,但不可能輸入不正確的值。

例如,使用者如果在列示方塊中選定州或國家,就無法輸入無效的州或國家的縮寫。

您可以讓使用者在列示方塊中選定一個值來移至某筆記錄。有時您也許想讓使用者自己選定所要檢視或編輯的資料記錄。例如,您可能為使用者提供了一個顧客姓名清單,當使用者從列示方塊中選定一個顧客時,需要同時選擇資料表格中那個顧客的記錄,並在表單的文字輸入方塊中顯示該顧客的有關訊息。可以有很多方法做到這一點,採用何種方法取決於表單中的資料來源。

------------------------------------------------------------------------------------------
RowSourceType  選定相對應記錄
---------------- -------------------------------------------------------------------------
2 - 別名     當使用者在列示方塊中選定一個值時,資料記錄指標將自動指向想要的記錄。
6 - 欄位     在列示方塊的 InteractiveChange 事件程序中使用 THISFORM.Refresh 方法程序,
         可讓表單中的其他控制項顯示新值。
------------------------------------------------------------------------------------------
0 - 無      在 InteractiveChange 事件中,選定包含所需記錄的資料表格,然後搜尋想要的
1 - 值      值。例如,如果 RowSource 屬性中擁有顧客資料表格中的顧客標識號碼,可使用下
3 - SQL 命令敘述 面的程式碼:
4 - 查詢    
5 - 陣列      SELECT customer
          LOCATE FOR THIS.Value = cust_id
          THISFORM.Refresh
------------------------------------------------------------------------------------------



相關資訊

用以顯示清單的控制項

使用控制項

在早期版本中建立的控制項和物件 




----------------------------------------------------------------------------------------------
原文:


How to: Allow Users to Add Items to a List Box 


You can make it possible for users to add items to a list interactively.



To make it possible for users to add items to a list interactively

•Use the AddItem method.

In the following example, when the user presses ENTER, the code in the KeyPress event of a text box adds the text in the text box to the list box and clears the text in the text box:

LPARAMETERS nKeyCode, nShiftAltCtrl
IF nKeyCode = 13  && Enter Key
  THISFORM.lstAdd.AddItem(This.Value)
  THIS.Value = ""
ENDIF

You can make it possible for users to enter data in a table from a list. If the ControlSource Property is set to a field, whatever the user selects in the list is written to the table. This is an easy way to help ensure the integrity of the data in your table. While the user can still enter the wrong data, an illegal value cannot be entered.

For example, if you have a list of states or counties for a user to choose from, the user cannot enter an invalid state or county abbreviation.

You can make it possible for users to navigate to a record by picking a value from a list. Often, you want to let users select the record they want to view or edit. For example, you could provide users with a list of customer names. When the user selects a customer from the list, you select that customer's record in the table and display customer information in text boxes on the form. You can do this several ways, depending on the source of data in your form.

--------------------------------------------------------------------------------------
RowSourceType   Selecting the appropriate record
----------------- --------------------------------------------------------------------
2 - Alias     When the user chooses a value in the list, the record pointer is set
6 - Fields    automatically to the desired record. Issue THISFORM.Refresh in the
         InteractiveChange event of the list to show the new values in other
         controls on the form.
--------------------------------------------------------------------------------------
0 - None     In the InteractiveChange event, select the table that has the record
1 - Value     with the desired values, and then search for the desired value. For
3 - SQL Statement example, if the RowSource holds customer identification numbers from
4 - QPR      the customer table, use this code:
5 - Array    
          SELECT customer
          LOCATE FOR THIS.Value = cust_id
          THISFORM.Refresh
--------------------------------------------------------------------------------------



See Also

Controls for Displaying Lists

Using Controls

Controls and Objects Created in Earlier Versions

_________________
希望有更多人來參與
VFP wiki - 需要大家一起完成的VFP電子書與FAQ
回頂端
檢視會員個人資料 發送私人訊息 發送電子郵件 MSN Messenger
朱育興



註冊時間: 2003-08-25
文章: 661
來自: 台中市大里區

第 200 樓

發表發表於: 星期二 一月 18, 2005 10:49 pm    文章主題: 引言回覆

如何:根據列示方塊值重新整理一對多的資料顯示


當使用者透過選定列示方塊中的一個值來移至某個記錄時,您可能需要一個一對多關聯性連結反應父資料表格中資料記錄指標的變化。利用本地資料表格以及本地資料集或遠端資料集都可以製作這一功能。

對於本地資料表格,如果列示方塊的 RowSourceType 屬性為 2 — 別名或 6 — 欄位,並且 RowSource 屬性是本地資料表格,該本地資料表格在表單的資料環境中具有設定關聯時,則當使用者選定新值時,可在 InteractiveChange 事件中使用 THISFORM.Refresh 方法程序。一對多關聯性連結中的“多”方會自動顯示與其關聯的父資料表格的運算式相符的記錄。

對於資料集,如果列示方塊的 RowSource 屬性是一個本地資料集或遠端資料集,則對一對多顯示的重新整理就有一些不同。 下面的範例描述在一個表單中所建立的列示方塊和多筆編輯控制項。列示方塊顯示 TESTDATA!Customer 資料表格的 cust_id 欄位的值。多筆編輯控制項顯示與在列示方塊中選定的 cust_id 欄位相關的訂單。

首先,在 [資料集設計工具] 中建立一個搜尋訂單的參數化資料集。當您在 [資料集設計工具] 中建立該資料集時,請將外部索引鍵值的選定條件設定到一個變數中。在下面的範例中,該變數稱為 m.cCust_id。



然後,當您設計表單時,請採用下列程序的步驟。請注意,該資料集需要一個參數值,該變數在載入表單之前是無法使用的。透過將資料集暫存資料表格物件的 NoDataOnLoad 屬性設定為真 (.T.),則只有於呼叫 REQUERY( ) 函數時才執行資料集,這時使用者可能已經為有參數化的資料集中使用的變數選定了一個值。



若要按本地資料集或遠端資料集設計一個一對多列示方塊

1.在 [資料環境] 加入資料表格和帶有參數化的資料集。

2.對於 [資料環境] 中的資料集暫存資料表格物件,在其 [屬性] 視窗中將 NoDataOnLoad 屬性設定為真 (.T.)。

3.將列示方塊的 RowSourceType 屬性設定為 [6 - 欄位],並且將列示方塊的 RowSource 屬性設定為在資料集的參數中參考為外部索引鍵值的欄位。

在範例中,您需要將 RowSource 屬性設定為 customer.cust_id。

4.將多筆編輯控制項的 RecordSource 屬性設定為您原先建立的資料集的名稱。

5.在列示方塊的 InteractiveChange 事件程式碼中,將列示方塊的值儲存在變數中,然後重新查詢資料集,如下例所示︰

m.cCust_id = THIS.Value
* 假設資料集的名稱為 orders_view
=REQUERY("orders_view")


有關本地資料集和遠端資料集的詳細內容,請參閱「建立資料集」。



相關資訊

用以顯示清單的控制項

使用控制項

在早期版本中建立的控制項和物件




----------------------------------------------------------------------------------------------
原文:


How to: Refresh a One-to-Many Display Based on a List Value


When the user chooses to go to a record by picking a value in a list, you might have a one-to-many relationship that needs to reflect the changed record pointer in the parent table. You can implement this functionality with both local tables and local or remote views.

For local tables, if the RowSourceType of the list is 2 - Alias or 6 - Fields and the RowSource is a local table with a relationship set in the form's data environment, issue THISFORM.Refresh in the InteractiveChange event when the user chooses a new value. The many sides of the one-to-many relationship automatically displays only the records that match the expression of the parent table involved in the relation.

For views, refreshing a one-to-many display is a little different if the RowSource of the list box is a local or remote view. The following example describes creating a form with a list box and a grid. The list box displays the values from the cust_id field in the TESTDATA!Customer table. The grid displays the orders associated with the cust_id field selected in the list box.

First, in the View Designer create a parameterized view for the orders. When you create the view in the View Designer, set the selection criterion for the foreign key to a variable. In the following example, the variable is called m.cCust_id.



Then, when you design the form, follow the steps in the following procedure. Note that the view requires a value for the parameter that is not available when the form is loaded. By setting the NoDataOnLoad Property of the view cursor object to true (.T.), you prevent the view from being run until the REQUERY( ) Function is called, at which time the user would have selected a value for the variable used in the parameterized view.



To design a one-to-many list based on local or remote views

1.Add the table and the parameterized view to the data environment.

2.In the Properties window for the view cursor object in the Data Environment, set the NoDataOnLoad property to true (.T.).

3.Set the RowSourceType property of the list box to 6 — Fields, and set its RowSource property to the field referenced as the foreign key in the view's parameter.

In the example, you would set the RowSource property to customer.cust_id.

4.Set the RecordSource property of the grid to the name of the view you created earlier.

5.In the InteractiveChange event code of the list box, store the value of the list box to the variable, and then requery the view, as in this example:

m.cCust_id = THIS.Value
*assuming the name of the view is orders_view
=REQUERY("orders_view")


For more information about local and remote views, see Creating Views.



See Also

Controls for Displaying Lists

Using Controls

Controls and Objects Created in Earlier Versions

_________________
希望有更多人來參與
VFP wiki - 需要大家一起完成的VFP電子書與FAQ
回頂端
檢視會員個人資料 發送私人訊息 發送電子郵件 MSN Messenger
朱育興



註冊時間: 2003-08-25
文章: 661
來自: 台中市大里區

第 201 樓

發表發表於: 星期三 一月 19, 2005 10:48 pm    文章主題: 引言回覆

如何:在列示方塊中顯示子記錄


在列示方塊中可以顯示一對多關聯性連結記錄,即資料記錄指標在父資料表格中移動時,顯示關聯中相對的子記錄。


若要在列示方塊中顯示子記錄

1.在表單中新增列示方塊。

2.將列示方塊的 ColumnCount 屬性設定為要顯示的行數。

例如,如果想在列示方塊中顯示 Order_id、Order_net 和 Shipped_on 三個欄位,應將 ColumnCount 屬性設定為 3。

3.根據要顯示的欄位,將 ColumnWidths 屬性設定為合適寬度。

4.將列示方塊的 RowSourceType 屬性設定為 [3 - SQL 命令敘述]。

5.將 RowSource 屬性設定為 SELECT 敘述。例如,下面的敘述根據顧客資料表格中的當前記錄從訂購資料表格中選定三個欄位:

SELECT order_id, order_net, shipped_on from orders ;
WHERE order.cust_id = customer.cust_id ;
INTO CURSOR temp

6.在表單的 Init 事件以及資料表格中移動資料記錄指標的程式碼中,重新查詢列示方塊:

THISFORM.lstChild.Requery



相關資訊

用以顯示清單的控制項

如何:使用檢核方塊指定狀態

使用控制項

在早期版本中建立的控制項和物件




----------------------------------------------------------------------------------------------
原文:


How to: Display Child Records in a List


You can display records from a one-to-many relationship in a list so that the list displays the child records in the relationship as the record pointer moves through the parent table.



To display child records in a list

1.Add a list to the form.

2.Set the ColumnCount property of the list to the number of columns you want to display.

For example, if you want to display the Order_id, Order_net, and Shipped_on fields in the list, set the ColumnCount property to 3.

3.Set the ColumnWidths property to the appropriate widths for displaying your selected fields.

4.Set the RowSourceType Property of the list to 3SQL Statement.

5.Set the RowSource Property to the SELECT statement. For example, the following statement selects three fields from the orders table for the current record in the customer table:

SELECT order_id, order_net, shipped_on from orders ;
WHERE order.cust_id = customer.cust_id ;
INTO CURSOR temp

6.In the Init Event of the form and in the code that moves the record pointer through the table, requery the list:

THISFORM.lstChild.Requery



See Also

Controls for Displaying Lists

How to: Use Check Boxes to Specify States

Using Controls

Controls and Objects Created in Earlier Versions

_________________
希望有更多人來參與
VFP wiki - 需要大家一起完成的VFP電子書與FAQ
回頂端
檢視會員個人資料 發送私人訊息 發送電子郵件 MSN Messenger
朱育興



註冊時間: 2003-08-25
文章: 661
來自: 台中市大里區

第 202 樓

發表發表於: 星期四 一月 20, 2005 11:37 pm    文章主題: 引言回覆

如何:將圖片新增到列示方塊項目中 


您可以在列示方塊的項目前面顯示圖片。



若要在列示方塊的項目前面顯示圖片

•將列示方塊的 Picture 屬性設定為圖形檔案。

相關詳細資訊請參閱「Picture 屬性 (Visual FoxPro)」和「在 Visual FoxPro 中所支援的圖形」。

例如,假設有一個檔案列示方塊,以及要根據檔案類型是資料表格、程式或其他檔案型態,在項目前顯示不同的圖形檔案。



下面的程式碼使用 FOR ... ENDFOR 命令在列示方塊的每個項目顯示不同的圖形檔案以及程式碼顯示在這個列示方塊的 Click 事件中:

FOR iItem = 5 TO THIS.ListCount   && 檔案從第五項開始
  cExtension = UPPER(RIGHT(THIS.List(iItem),3))
  DO CASE
   CASE cExtension = "DBF"
     THIS.Picture(iItem) = "tables.bmp"
   CASE cExtension = "BMP"
     THIS.Picture(iItem) = "other.bmp"
   CASE cExtension = "PRG"
     THIS.Picture(iItem) = "programs.bmp"
   CASE cExtension = "SCX"
     THIS.Picture(iItem) = "form.bmp"
   OTHERWISE
     THIS.Picture(iItem) = IIF("]" $ cExtension, ;
      "", "textfile.bmp")
  ENDCASE
ENDFOR

相關詳細資訊請參閱「Click 事件」。



相關資訊

用以顯示清單的控制項

如何:使用檢核方塊指定狀態

用以接受輸入的控制項

使用控制項

在早期版本中建立的控制項和物件 




----------------------------------------------------------------------------------------------
原文:


How to: Add Pictures to Items in a List 


You can display pictures next to items in lists.



To display pictures next to items in a list

•Set the Picture property to a graphic file for the list box.

For more information, see Picture Property (Visual FoxPro) and Graphics Support in Visual FoxPro.

For example, suppose you populate a list box with files and want to display a different graphics file next to each file depending on whether the file is table, a program, or some other file type.



The following code uses the FOR ... ENDFOR command to

displays a different graphics file for each item in the list and appears in the Click event of this list box:

FOR iItem = 5 TO THIS.ListCount   && files start at the 5th item
  cExtension = UPPER(RIGHT(THIS.List(iItem),3))
  DO CASE
   CASE cExtension = "DBF"
     THIS.Picture(iItem) = "tables.bmp"
   CASE cExtension = "BMP"
     THIS.Picture(iItem) = "other.bmp"
   CASE cExtension = "PRG"
     THIS.Picture(iItem) = "programs.bmp"
   CASE cExtension = "SCX"
     THIS.Picture(iItem) = "form.bmp"
   OTHERWISE
     THIS.Picture(iItem) = IIF("]" $ cExtension, ;
      "", "textfile.bmp")
  ENDCASE
ENDFOR

For more information, see Click Event.



See Also

Controls for Displaying Lists

How to: Use Check Boxes to Specify States

Controls for Accepting Input

Using Controls

Controls and Objects Created in Earlier Versions

_________________
希望有更多人來參與
VFP wiki - 需要大家一起完成的VFP電子書與FAQ
回頂端
檢視會員個人資料 發送私人訊息 發送電子郵件 MSN Messenger
朱育興



註冊時間: 2003-08-25
文章: 661
來自: 台中市大里區

第 203 樓

發表發表於: 星期六 一月 22, 2005 6:50 am    文章主題: 引言回覆

用以接受輸入的控制項


要能預先確定使用者對控制項輸入的所有可能值是困難的。下面的控制項可以讓您接收無法預先確定的使用者輸入:

文字輸入方塊
文書編輯方塊
下拉式列示方塊



在本章節中


使用者在文字輸入方塊中輸入

描述文字輸入方塊如何讓使用者輸入或編輯儲存在非附註欄位的資料。


使用者在文書編輯方塊中輸入

描述文書編輯方塊如何讓使用者在字元欄位或附註欄位中編輯文字。


使用者在下拉式列示方塊中輸入

描述下拉式列示方塊如何讓使用者選取清單中的項目或者輸入新項目。


如何:使用檢核方塊指定狀態

描述檢核方塊如何讓使用者指定一個布林狀態。


如何:定義使用者輸入的特性

描述如何控制使用者鍵入的輸入型態。


接受指定範圍內的數值輸入

描述如何確保使用者輸入的值在特定範圍內。


如何:設定選項按鈕組中的選項按鈕數目

描述如何設定使用者可以選取的選項按鈕數目。


設定選項按鈕的屬性

描述如何設定選項按鈕的屬性。


如何:使用選項按鈕將使用者的選定儲存到資料表格中

描述如何使用選項按鈕取得資訊以及將它儲存到資料表格中。



相關章節


使用控制項

描述可以利用各種控制項來改善使用者與應用程式之間的對話模式。


用以顯示清單的控制項

描述列示方塊與下拉式列示方塊的一般用途、方法程序和屬性。


用以顯示訊息的控制項

說明可顯示和排序訊息的各種 Visual FoxPro 的控制項與物件。


用以處理資料記錄的控制項

描述 Visual FoxPro 的多筆編輯控制項之一般用途、方法程序和屬性。


用以允許特定指令的控制項

描述 Visual FoxPro 的控制項允許使用者透過使用者界面或者計時延遲來使用特定預先編寫好的指令。


用以加強表單功能的控制項

描述分頁框物件和使用 ActiveX 控制項如何擴充可使用工作區以及使用的 Visual FoxPro 表單。  




----------------------------------------------------------------------------------------------
原文:


Controls for Accepting Input


It is difficult to anticipate all the values that a user might need to enter into a control. The following controls make it possible for you to accept user input that cannot be predetermined:

Text boxes
Edit boxes
Combo boxes



In This Section


User Input in Text Boxes

Describes how text boxes make it possible for users to enter or edit data stored in non-memo fields.


User Input in Edit Boxes

Describes how edit boxes make it possible for users to edit text from character fields or memo fields.


User Input in Combo Boxes

Describes how combo boxes make it possible for users to select items from a list or enter new items.


How to: Use Check Boxes to Specify States

Describes how check boxes make it possible for users to specify a Boolean state.


How to: Define User Input Characteristics

Describes how to control the type of input the user enters.


Accepting Numeric Input in a Given Range

Describes how to ensure that users enter values within a specific range.


How to: Set the Number of Option Buttons in an Option Button Group

Describes how to set the number of option buttons that the user can choose from.


Setting Option Button Properties

Describes how to set properties for option buttons.


How to: Store User Choices to a Table Using Option Buttons

Describes how to use option buttons obtain information and store it in a table.



Related Sections


Using Controls

Describes controls you can use to manage interactions between users and your application.


Controls for Displaying Lists

Describes the common uses, methods, and properties of list boxes and drop-down list boxes.


Controls for Displaying Information

Explains various Visual FoxPro controls and objects that can display and order information.


Controls for Manipulating Rows of Data

Describes the common uses, methods, and properties of the Visual FoxPro grid control.


Controls for Allowing Specific Actions

Describes the Visual FoxPro controls that allow users to take specific preprogrammed actions either by user interaction or by timed delay.


Controls for Extending Forms

Describes how the Page Frame object and the use of ActiveX controls can expand the workable area and use of Visual FoxPro forms.

_________________
希望有更多人來參與
VFP wiki - 需要大家一起完成的VFP電子書與FAQ
回頂端
檢視會員個人資料 發送私人訊息 發送電子郵件 MSN Messenger
朱育興



註冊時間: 2003-08-25
文章: 661
來自: 台中市大里區

第 204 樓

發表發表於: 星期六 一月 22, 2005 6:51 am    文章主題: 引言回覆

此 Beta 版的翻譯到此結束,正式版的發表模式將不定期 (依翻譯的速度而定) 發表,但不再採取逐篇發表模式,其每次依一個段落以 CHM 檔格式上傳供有興趣的人下載
_________________
希望有更多人來參與
VFP wiki - 需要大家一起完成的VFP電子書與FAQ
回頂端
檢視會員個人資料 發送私人訊息 發送電子郵件 MSN Messenger
ping362421



註冊時間: 2015-08-21
文章: 2


第 205 樓

發表發表於: 星期一 十二月 07, 2015 3:50 pm    文章主題: 引言回覆

正體字閱讀起來好別扭,樓主前輩辛苦了
回頂端
檢視會員個人資料 發送私人訊息 發送電子郵件
從之前的文章開始顯示:   
發表新主題   回覆主題    VFP 愛用者社區 首頁 -> VFP 討論區 所有的時間均為 台北時間 (GMT + 8 小時)
前往頁面 上一頁  1, 2, 3 ... 12, 13, 14
14頁(共14頁)

 
前往:  
無法 在這個版面發表文章
無法 在這個版面回覆文章
無法 在這個版面編輯文章
無法 在這個版面刪除文章
無法 在這個版面進行投票
無法 在這個版面附加檔案
無法 在這個版面下載檔案


Powered by phpBB © 2001, 2005 phpBB Group
正體中文語系由 phpbb-tw 維護製作