如何将数据库中的 idnum 存储到 combobox,以便我可以编辑和更新记录。
我不知道这是我第一次使用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"
确保在
执行代码之前先打开表。检查这个 http://msdn.microsoft.com/en-us/library/ykwzk7h2(v=vs.80).aspx
尽管 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