|
-
Feb 21st, 2024, 05:44 PM
#5
Thread Starter
Frenzied Member
Re: Populating a Combobox display/value of states from text file
 Originally Posted by jmcilhinney
When the Sorted property is True, it seems not to be honouring the DisplayMember based on that code. It seems to be displaying the result of calling ToString on each item rather than using the DisplayMember. I just tested with a custom type instead of a Tuple and got the type name in the control, which would be what you'd see if you hadn't set the DisplayMember. As a rule, you should always set the DataSource after the DisplayMember and ValueMember. There are often exceptions to rules though, and this is one such exception. If you set the DataSource first and then the DisplayMember and ValueMember, the data is displayed correctly. That goes for Tuples and custom types.
Thanks, that works. I would think that sorting the datasource first would also work, but I haven't tried that. Is there any way to do that with the code you posted in #2?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|