highlighting text in a combo box with the mouse
-
Hello, Is there any way to work around the .Net bug that doesn't allow text in a combobox to be highlighted with the mouse? This seems like something that any combobox should allow. Thanks, Blake
It depends on the
ComboBox.DropDownStyle
style. If you're usingComboBoxStyle.DropDown
, you can select and enter new text. If you useComboBoxStyle.DropDownList
then only the list items in thatComboBox
can be select and, hence, there is no need to highlight certain text. This behavior is defined by the Combo Box Common Control which the .NETComboBox
class encapsulates, hence the behavior is the same for native Combo Box controls in Win32 applications. This is not a bug.-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
-
It depends on the
ComboBox.DropDownStyle
style. If you're usingComboBoxStyle.DropDown
, you can select and enter new text. If you useComboBoxStyle.DropDownList
then only the list items in thatComboBox
can be select and, hence, there is no need to highlight certain text. This behavior is defined by the Combo Box Common Control which the .NETComboBox
class encapsulates, hence the behavior is the same for native Combo Box controls in Win32 applications. This is not a bug.-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
Actually, you can't select the text even if you are using DropDown instead of DropDownList. You can edit the text and enter new text, but you can't highlight the text with the mouse like you normally can in an edit box. You can use shift and the arrow keys to highlight text, but holding down the mouse button and moving the mouse will not work. I've read on the internet that this is a bug. Does any one know of any combobox controls on the internet that might fix this bug, or would the only way to get around it be capturing the mouse events and trying to do it on my own? Thanks, Blake
-
Actually, you can't select the text even if you are using DropDown instead of DropDownList. You can edit the text and enter new text, but you can't highlight the text with the mouse like you normally can in an edit box. You can use shift and the arrow keys to highlight text, but holding down the mouse button and moving the mouse will not work. I've read on the internet that this is a bug. Does any one know of any combobox controls on the internet that might fix this bug, or would the only way to get around it be capturing the mouse events and trying to do it on my own? Thanks, Blake
Works in .NET 1.1, but I did notice it doesn't work in .NET 1.0. Never noticed that. If you can, upgrade your code base to 1.1. It does contain enhancements and bug fixes (like for this bug! :)) after all. If not, you could implement this using the mouse events or overriding
WndProc
in a derived class and handling the notification messages, though doing all that should be exposed through mouse events and managed methods already (at least in this case). Note that creating such a work around will probably break the correct behavior when run under .NET 1.1.-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
-
Works in .NET 1.1, but I did notice it doesn't work in .NET 1.0. Never noticed that. If you can, upgrade your code base to 1.1. It does contain enhancements and bug fixes (like for this bug! :)) after all. If not, you could implement this using the mouse events or overriding
WndProc
in a derived class and handling the notification messages, though doing all that should be exposed through mouse events and managed methods already (at least in this case). Note that creating such a work around will probably break the correct behavior when run under .NET 1.1.-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----