RE: Keep ID-value after using Combobox
Off topic, but I'll field it...
Use SetItemData to associate a DWORD with each entry in the combo.
E.g.
combo->SetItemData( combo->AddString(
it->UrensoortOmschrijving.c_str() ), ID_Value );
Then use this to get the value back.
combo->GetItemData( curSel );
Or use the analogous SendMessage calls.
-----Original Message-----
From: Maarten Schrijvers [mailto:maarten.schrijvers@gmail.com]
Sent: Wednesday, July 25, 2007 11:30 AM
To: plusplus@lists.mysql.com
Subject: Keep ID-value after using Combobox
I want my users to pick an item in a Windows Forms combobox. To fill
that combobox I use a SSQLS like so:
sql_create_2(TblUrensoort, 2, 0, string, UrensoortOmschrijving, int,
UrensoortID);
--
mysqlpp::Query qUrensrt = con.query();
qUrensrt << "select UrensoortOmschrijving, UrensoortID from
TblUrensoort";
vector resUrensrt;
qUrensrt.storein(resUrensrt);
cBUren->Items->Clear(); //empty the combobox
vector::iterator it;
mysqlpp::Row rowUrensrt; //still here from an attempt without SSQLS
for (it = resUrensrt.begin(); it != resUrensrt.end(); ++it) {
String ^ a = gcnew String(it->UrensoortOmschrijving.c_str());
AddMessage(a);// AddMessage function like it is in the example.
}
This works just OK, but this way, through the conversion, I disconnect
the ID and the String.
Now here's my problem: After my user has made a choice, I want to
continue in my program with the "ID-value" instead of the
"String-value". But as far as I can see there is no way that I can get
the two "connected" again as they were in the vector. (Without doing
another query!)
I have thought about using an Arraylist, but since I would have to fill
that with the values from the vector that idea seems to me like
reinventing the wheel.
Can anybody enlighten me?
--
MySQL++ Mailing List
For list archives:
http://lists.mysql.com/plusplus
To unsubscribe:
http://lists.mysql.com/plusplus?unsub=lists@pantek.com
Received on Wed Jul 25 11:58:52 2007
This archive was generated by hypermail 2.1.8
: Thu Aug 09 2007 - 19:28:34 EDT
|