如何在foxpro 9中将数据库中的值存储到组合框中?

时间:2014-02-22 07:26:32

标签: foxpro visual-foxpro

如何将我的数据库中的idnum存储到组合框中,以便我可以编辑和更新记录 我不知道这是我第一次使用foxpro。

my database name is emp4win.
i need to get the idnum and store to combobox for editing
i tried this one
Form1.lstMyList.RowSourceType = 2
Form1.lstMyList.RowSource = "emp4win"

2 个答案:

答案 0 :(得分:0)

确保在代码执行之前先打开表。检查此http://msdn.microsoft.com/en-us/library/ykwzk7h2(v=vs.80).aspx

答案 1 :(得分:0)

虽然来自NullReferenceException的答案是一个好的开始,但我没有看到关于绑定ID的真正帮助的参考。我将使用的组合框的属性是

RowSource = "tableNameThatHasTheRecords"

&& Dropdown list only allows those values in the table as valid
&& Dropdown COMBO allows the list OR manually entered values, but you have to deal with what if the entered value is not in the table... add it or what.
Style = 2  && List
Style = 0  && Combo

&& Fields.  You want to display values from the columns in your table
RowSourceType = 6


&& Columns in the order you want displayed.  However, if dealing with an "ID" Column that you don't necessarily want to show the user, this would typically be put LAST in the list of columns presented
RowSource = "ColumnX, ColumnY, IDColumn"


&& ColumnWidths is how wide you want each column when the drop-down is exposed.  The first column is always shown in the combobox, but when in drop-down mode, will show all 3 columns possible, but since this example has the third column width of 0, it will NOT actually show the column value.  (such as internal auto-increment ID that would otherwise mean nothing to the end-user).
ColumnWidths = "160, 85, 0"

&& How many columns in the row source that you have specifically made available
ColumnCount = 3  

&& BOUND COLUMN is the key one for you.  Which column of the row source do you want the value returned to the control's ".Value".  In this case, column 3, the ID column even though the display width is zero, it will still put the ID as the selected value
BoundColumn = 3