I have a combobox bound to a dataset containing States and their corresponding ID's. How would I set the combobox selection to the textvalue retrieved from the database? In Windows forms I would do something like this, however my understanding is that FindString is not available in the compact framework: cboState.SelectedIndex = cboState.FindString(value) I have read that an alternative is to iterate through the items collection, however I can't seem to get this to work. Any sample code to accomplish this would be much appreciated.
It is possible to recreate this method with a little bit of native interop since the underlying control supports the windows message to do the find. I posted the details here:- http://inthehand.com/blogs/peterfoot/archive/2008/07/10/implement-findstring-for-a-combobox.aspx Peter -- Peter Foot Microsoft Device Application Development MVP peterfoot.net | appamundi.com | inthehand.com APPA Mundi Ltd - Software Solutions for a Mobile World In The Hand Ltd - .NET Components for Mobility "tthompson2007" wrote in message news:5051BBC3-23D7-4B96-8A86-E2F57A39BB6B@microsoft.com... >I have a combobox bound to a dataset containing States and their > corresponding ID's. How would I set the combobox selection to the > textvalue > retrieved from the database? > > In Windows forms I would do something like this, however my understanding > is > that FindString is not available in the compact framework: > > cboState.SelectedIndex = cboState.FindString(value) > > I have read that an alternative is to iterate through the items > collection, > however I can't seem to get this to work. Any sample code to accomplish > this > would be much appreciated.
Thanks for your help Peter. By the way...I've gotten a lot of use out of your book. Mobile Development Handbook. "Peter Foot" wrote in message news:63746CFC-9D74-40CB-8373-D7EAD7107F26@microsoft.com... > It is possible to recreate this method with a little bit of native interop > since the underlying control supports the windows message to do the find. > I posted the details here:- > http://inthehand.com/blogs/peterfoot/archive/2008/07/10/implement-findstring-for-a-combobox.aspx > > Peter > > -- > Peter Foot > Microsoft Device Application Development MVP > peterfoot.net | appamundi.com | inthehand.com > APPA Mundi Ltd - Software Solutions for a Mobile World > In The Hand Ltd - .NET Components for Mobility > > "tthompson2007" wrote in message > news:5051BBC3-23D7-4B96-8A86-E2F57A39BB6B@microsoft.com... >>I have a combobox bound to a dataset containing States and their >> corresponding ID's. How would I set the combobox selection to the >> textvalue >> retrieved from the database? >> >> In Windows forms I would do something like this, however my understanding >> is >> that FindString is not available in the compact framework: >> >> cboState.SelectedIndex = cboState.FindString(value) >> >> I have read that an alternative is to iterate through the items >> collection, >> however I can't seem to get this to work. Any sample code to accomplish >> this >> would be much appreciated. >