Setting the combobox selection based on value instead of index


Author
Message
Andria Jensen
Andria Jensen
Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)
Group: Forum Members
Posts: 336, Visits: 497
I'm using the Inherited UI ComboBoxEdit and I want to save the selection of this and a bunch of other combos on a form and then be able to restore them when I come back to that same form.  The ValueMember and DisplayValue properties may not be the same and for other reasons I need to save out the SelectedValue instead of the SelectedIndex.  I can save it out just fine using the SelectedValue property.  Is there a way to just set a property on the combo box and have it select the corresponding item in the list when I go to restore my selections?  I tried setting SelectedValue to the value which was saved out, but this does not work.  I was going to just right a little method to search through the Items collection and set SelectedIndex based on which item matches the saved SelectedValue.  I just wanted to make sure there wasn't an easier way before I implement unnecessary code.  Thanks Smile
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
You should be able to set the SelectedValue property directly, however, there was a logic error in the way that the indexor for the items collection was being called... if the type of the selected value was an integer, then the wrong overload was being called and it would not have given you the correct functionality.  I fixed it and we're going to post an update later today, probably within the next couple of hours.  I'll let you know.
Andria Jensen
Andria Jensen
Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)
Group: Forum Members
Posts: 336, Visits: 497
Awesome, thanks!  Yes, the one I was having problems with specifically was using an  integer value as the ValueMember.  That's probably where my problem is coming from.  Let me know when I can download the update.  Thanks again.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search