473,654 Members | 2,974 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

KeyPreview does not intercept keys in Combo Box

Hi:

On my form, I have textbox and combo box. Form's KeyPreview = True. It does
work for the textbox, but not for the combo. I.e.

Private Sub Form1_KeyPress( ByVal sender As Object, ByVal e As
System.Windows. Forms.KeyPressE ventArgs) Handles MyBase.KeyPress
me.Text = e.KeyChar
End Sub

does intercept keys pressed in the textbox, but not in the combobox. Is
there any explanation for this?

thanks,

Vadim

Nov 20 '05 #1
3 2350
* "Vadim Rapp" <vr@myrealbox.n ospam.com> scripsit:
On my form, I have textbox and combo box. Form's KeyPreview = True. It does
work for the textbox, but not for the combo. I.e.

Private Sub Form1_KeyPress( ByVal sender As Object, ByVal e As
System.Windows. Forms.KeyPressE ventArgs) Handles MyBase.KeyPress
me.Text = e.KeyChar
End Sub

does intercept keys pressed in the textbox, but not in the combobox. Is
there any explanation for this?


Which version of .NET do you use? AFAIK this is a bug in .NET 1.0.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
HKW> Which version of .NET do you use? AFAIK this is
HKW> a bug in .NET 1.0.

1.1.4322

Vadim
Nov 20 '05 #3
if you use it on the combo iself it wil work (i use that a lot)
Private Sub cboLijn_KeyPres s(ByVal sender As Object, ByVal e As
System.Windows. Forms.KeyPressE ventArgs) Handles cboLijn.KeyPres s

if you want the form keypress events i suggest you use this (from the 'enter
key' thread tnx to the ppl that replied there :)

Turn "KeyPreview ON" for the form before your try this code:
Private Sub Form1_KeyDown(B yVal sender As Object, ByVal e As
System.Windows. Forms.KeyEventA rgs) Handles MyBase.KeyDown

If e.KeyCode = Keys.Enter Then
If Not ActiveControl Is Nothing Then
SendKeys.Send(" {TAB}")
End If
End If

End Sub


"Vadim Rapp" <vr@myrealbox.n ospam.com> wrote in message
news:Oo******** ******@TK2MSFTN GP11.phx.gbl...
Hi:

On my form, I have textbox and combo box. Form's KeyPreview = True. It does work for the textbox, but not for the combo. I.e.

Private Sub Form1_KeyPress( ByVal sender As Object, ByVal e As
System.Windows. Forms.KeyPressE ventArgs) Handles MyBase.KeyPress
me.Text = e.KeyChar
End Sub

does intercept keys pressed in the textbox, but not in the combobox. Is
there any explanation for this?

thanks,

Vadim

Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1694
by: Carl Tribble | last post by:
I am using KeyPreview on the form to trap Function-keys. My form includes a datagrid. I am using the Form.KeyDown event to trap the keys and all works fine unless the datagrid is showing one or more rows and the focus is in a column on one of the datagrid's rows. Then, pressing a function key does not seem to execute the Form.KeyDown event. How can I trap and detect which function key a user pressed at the form level from inside of a...
1
4489
by: Ori | last post by:
Hi Guys, Here is my problem, but maybe someone can help me with this. Background: 1. Using C#. 2. I'm having a form which the KeyPreview is on (and must stay like this) and I'm implementing some functions on the Key up event of some controls and the form.
1
3221
by: ray well | last post by:
hi, i need to preview the keys in my app in order to process F1-F10. i set keypreview of my form to true, and it does capture the keystrokes from all over the forms controls which i then process. i found 2 puzzeling exception: if the user is inside the text box of a ComboBox, the keystrokes aren't captured in the form's keypress event. i have to separately capture the
1
6170
by: Rene | last post by:
Hi, I am running is some problems with the KeyPreview and KeyPress events. The KeyPress event is only triggered when there this an focusable control on the form. When all controls are disabled the Form.KeyPress event does not trigger anymore. A way to 'solve' this is to set the focus to the form, but during testing it happens ofter the keypress event is not getting triggered on keys like
13
3844
by: HABJAN ®iga | last post by:
I'am using form's keypreview property & keydown (on form) to look for hotkeys (alt+?) Everything works fine, except when i have focus on combobox. Then the event on form isn't raised. Can some one tell me why & how can it be done? best regards, habix
9
8283
by: Charles Law | last post by:
I have asked a similar question to this before, but have not found a satisfactory answer yet, so I thought I would ask it in another way. KeyPreview, for a form, handily allows keys to be intercepted at form level, and pre-processed and/or filtered. In the absence of a MousePreview setting, is there a way to do the same thing for mouse movements and clicks? TIA Charles
0
830
by: ray well | last post by:
hi, i need to preview the keys in my app in order to process F1-F10. i set keypreview of my form to true, and it does capture the keystroke which i can process. if the user types into the text box of a ComboBox, the keystrokes aren't captured in the form's keypress event. likewise if the user types inside of a cell in a datagrid control the keystrokes again aren't captured in the form.
1
2404
by: Lou | last post by:
I have an activeX control in my .NET app that steels the "Delete" key, How can I Steel the key first. I tried the KeyPreview but that doesn't get the key first. -Louie
115
6218
by: LurfysMa | last post by:
Most of the reference books recommend autonum primary keys, but the Access help says that any unique keys will work. What are the tradeoffs? I have several tables that have unique fields. Can I use them as primary keys or should I define an autonum primary key? One table has information about the 50 states in the US. The table looks like this:
0
8815
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8707
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8482
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8593
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7306
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6161
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5622
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1593
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.