2014-02-22 50 views
0

如何將我的數據庫中的idnum存儲到組合框中,以便我可以編輯和更新記錄。
我不知道這是我第一次使用foxpro。
如何將數據庫中的值存儲到foxpro 9中的combox中?

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" 

回答

0

確認表的代碼之前先打開executes.Check這http://msdn.microsoft.com/en-us/library/ykwzk7h2(v=vs.80).aspx

+0

我不明白如何打開數據庫?我應該在哪裏放置代碼? – Reynan

+0

打開數據庫數據庫名,並使用像USE表名的表名,並檢查這個綁定http://stackoverflow.com/questions/9827957/foxpro-databinding-how-to-se-the-controlsource-and-the-display-source -properti?rq = 1 – NullReferenceException

+0

這是最好的tutorial.go通過它 NullReferenceException

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 
相關問題