This code is used in a Delphi form fmUserData, and is called on form.show, not create, to ensure data in combo box is up to date
The application uses MySQL server for data storage
cbucurr is a combo box in form fmUserData
// populate the strings list for the cbucurr combobox
fmUserData.cbucurr.items.clear; // make sure the combobox strings list is empty
fmUserData.qCurr.close; // qCurr is an ADO query linked to a table tCurr via an ADOConnection.
//My qCurr has a fixed SQL Select string that selects all currency codes, but you could insert a
// runtime select statement into the SQL.text property of qCuirr here
// My fixed SQL string is simply 'Select currcode from tcurr' ie I want all codes in tcurr
fmUserData.qCurr.open; // runs whatever select statement you have put in place
fmUserData.qCurr.first;
while (not fmUserData.qCurr.eof) do
begin
cbucurr.items.add(qcurr.FieldByName('currcode').asstring);
// in above line, currcode is a field in the MySQL table tcurrr
fmUserData.qCurr.next;
end;
I have the combobox set to uppercase and to sort the list automatically.
Hope this helps.
Last Wiki Answer Submitted: January 30, 2009 4:35 am by HalC15 pts.
If you live outside the United States, by submitting your email address you consent to having your personal data transferred to and processed in the United States.
What programming language are you using? It will be different in each language.
Kiti, to provide more information on your question — simply click the “Discuss This Answer” button. Your comment will appear below. Thanks!
Uh Brent, the button actually says “ADD TO DISCUSSION”.