PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Framework Forms
Form's KeyDown delegate not called when in DropDownList ComboBox
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Framework Forms
Form's KeyDown delegate not called when in DropDownList ComboBox
![]() |
Form's KeyDown delegate not called when in DropDownList ComboBox |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
I have a form with a delegate set up for the KeyDown event. I have set KeyPreview=true and the delegate is called correctly whenever I press a key, except if the active control on that form is a DropDown ComboBox.
If I change that ComboBox to be DropDownStyle=ComboBoxStyle.DropDowList the delegate fires when I press a key in that control, as I would expect. The problem is I don't want to restrict the ComboBox to a fixed list of options. The user needs to be able to select, or type their own option. I have reproduced this in an extremely trivial app - one form, two comboboxes, one delegate, and no databinding etc. Does anyone know whether I could be doing something else that has created this problem, or whether this is a known bug? I have searched but can't find a post that seems relevant. Thanks, Scott. |
|
|
|
#2 |
|
Guest
Posts: n/a
|
I reproduced this exactly as you've described.
The only work around I see is to assign the form's delegate to the dropdown lists' KeyDown event hope you do not have too much dropdown lists on the form |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Hi Scott,
I can reproduce this issue on my system too, It seems this behavior is inconsistent with the same scenario in VB6. I'll forward this issue to the product team to let them investigate it. In the meantime, you may try workaround to see if could resolve this problem: <code> class MyComboBox : ComboBox { protected override bool ProcessKeyEventArgs(ref Message m) { if ( this.DropDownStyle == ComboBoxStyle.DropDown && this.ProcessKeyPreview ( ref m ) ) { return true; } return base.ProcessKeyEventArgs (ref m); } } </code> Please feel free to reply this thread if you still have problem on this issue. Thanks! Best regards, Ying-Shen Yu [MSFT] Microsoft Community Support Get Secure! - www.microsoft.com/security This posting is provided "AS IS" with no warranties and confers no rights. This mail should not be replied directly, please remove the word "online" before sending mail. |
|
|
|
#4 |
|
Guest
Posts: n/a
|
Yes. That works for me.
I'm not exactly sure what it is doing, but assume this is the magic couple of lines of code that is missing from the ComboBox control. I also had success with wiring up the KeyDown event for each DropDown style ComboBox, but as the previous reply points out, this is quite tedious if you have more than a couple. Is this something MSFT is likely to fix in a .Net Framework update or do we wait for Longhorn? Thanks for your help, Scott. ""Ying-Shen Yu[MSFT]"" wrote: > Hi Scott, > > I can reproduce this issue on my system too, > It seems this behavior is inconsistent with the same scenario in VB6. > I'll forward this issue to the product team to let them investigate it. > In the meantime, you may try workaround to see if could resolve this > problem: > <code> > class MyComboBox : ComboBox > { > protected override bool ProcessKeyEventArgs(ref Message m) > { > if ( this.DropDownStyle == ComboBoxStyle.DropDown && > this.ProcessKeyPreview ( ref m ) ) > { > return true; > } > return base.ProcessKeyEventArgs (ref m); > } > } > </code> > > Please feel free to reply this thread if you still have problem on this > issue. > > Thanks! > > Best regards, > > Ying-Shen Yu [MSFT] > Microsoft Community Support > Get Secure! - www.microsoft.com/security > > This posting is provided "AS IS" with no warranties and confers no rights. > This mail should not be replied directly, please remove the word "online" > before sending mail. > > |
|
|
|
#5 |
|
Guest
Posts: n/a
|
Hi Scott,
I'm glad to see the workaround could resolve your problem, I have forward to our product group, they will investigate it further and decide how to fix it and do complete tests, since the process was just began, it's hard to say which release will include this fix. Thanks for your understanding. Best regards, Ying-Shen Yu [MSFT] Microsoft Community Support Get Secure! - www.microsoft.com/security This posting is provided "AS IS" with no warranties and confers no rights. This mail should not be replied directly, please remove the word "online" before sending mail. |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

