Groups | Blog | Home
all groups > dotnet compact framework > october 2004 >

dotnet compact framework : Deselecting a value in a combo box


Alex Feinman [MVP]
10/7/2004 9:06:18 AM
Funny thing this is exactly the problem I hit last night. Databinding clears
listbox but setting selectedindex or selectedvalue does not. Next thing I'm
going to try is setting selectedindex via SendMessage. Let's keep each other
posted.

--
Alex Feinman
---
Visit http://www.opennetcf.org
[quoted text, click to view]

Alex Feinman [MVP]
10/7/2004 10:01:06 AM
Thanks, Tim.
Peter Foot and I have both confirmed that the KB article is applicable and
addresses exactly the issue we are seeing. The workaround works. As an
alternative, sending CB_SETCURSEL (0x14e) also works although there is a
potentially useful side effect of SelectionChanged not being fired

--
Alex Feinman
---
Visit http://www.opennetcf.org
[quoted text, click to view]

Tim Wilson
10/7/2004 12:29:32 PM
I don't know if you've already seen this information, or if it even applies
in this case since it's related to the full framework, but I'll pass it
along anyways...
http://support.microsoft.com/default.aspx?scid=kb;en-us;327244

--
Tim Wilson
..Net Compact Framework MVP

[quoted text, click to view]

Tim Wilson
10/7/2004 12:57:17 PM
Cool. Nice job!

--
Tim Wilson
..Net Compact Framework MVP

[quoted text, click to view]

Jon Skeet [C# MVP]
10/7/2004 2:34:32 PM
I've got two combo boxes which are somewhat linked - the second one is
only valid if the first one has a certain value.

When I change the first one to a different value, I want to deselect
whatever's in the second box, leaving it blank. It's definitely
possible, because the databinding does is when we first enter the form
- the value is DBNull, and it manages to clear the box.

According to the docs, setting the SelectedIndex to -1 should do it -
but it doesn't. It just sets the index to 0 instead. However, bizarrely
enough, setting the SelectedIndex from the command window in the
debugger does exactly the right thing.

Any suggestions as to what might be going on?

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
Peter Foot [MVP]
10/7/2004 5:51:08 PM
Thats just the ticket! Setting it twice works.

I put together a number of ComboBox "bug-fixes" into a ComboBoxEx class -
posted the code to my blog here:-
http://blog.opennetcf.org/pfoot/PermaLink.aspx?guid=dd0fe46e-dd82-428c-9982-323ef182f25c

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

Do have an opinion on the effectiveness of Microsoft Windows Mobile and
Embedded newsgroups? Let us know!
https://www.windowsembeddedeval.com/community/newsgroups

[quoted text, click to view]

Jon Skeet [C# MVP]
10/7/2004 6:33:42 PM
[quoted text, click to view]

Oh good grief... thanks very much. Oddly enough, that's something I
wouldn't have thought of doing :)

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
AddThis Social Bookmark Button