It took me a while to find this code, so I decided to post it here for
others who might also be looking for a way to trap tab key presses. You can
extend a control and place this code in it to raise a custom TabKeyDown
event. Here is an example of how you might extend a TextBox control to
provide this event:
Public Class TextBoxEx
Inherits TextBox
Const WM_KEYDOWN As Integer = &H100
Const WM_SYSKEYDOWN As Integer = &H104
Public Event TabKeyDown(ByVa l CtrlPressed As Boolean, _
ByVal ShiftPressed As Boolean)
Protected Overrides Function ProcessCmdKey(B yRef msg As Message, _
ByVal keyData As Keys) As Boolean
' If a key or system key is pressed...
If ((msg.Msg = WM_KEYDOWN) Or (msg.Msg = WM_SYSKEYDOWN)) Then
' If the tab key is pressed...
If keyData = Keys.Tab Then
' The user pressed the tab key (without holding ctrl,
' shift, or alt)
RaiseEvent TabKeyDown((key Data And Keys.Control) = _
Keys.Control, (keyData And Keys.Shift) = Keys.Shift)
' If the tab key was pressed along with one or more
' other system keys...
ElseIf (keyData And Keys.Tab) = Keys.Tab Then
' The user held ctrl shift or alt and pressed the tab key
' Note: I don't bother to trap for the Alt key because
' Alt-Tab switches focus to another app and yours
' will not receive the message anyway.
RaiseEvent TabKeyDown((key Data And Keys.Control) = _
Keys.Control, (keyData And Keys.Shift) = Keys.Shift)
End If
End If
' Let base class handle the key press
Return MyBase.ProcessC mdKey(msg, keyData)
End Function
End Class
- Don 2 7054
Don,
Is this not easier?
\\\
Private Sub TextBox1_KeyUp( ByVal sender As Object, _
ByVal e As System.Windows. Forms.KeyEventA rgs) _
Handles TextBox1.KeyUp
If e.KeyData = Keys.Tab Then
MessageBox.Show ("Hello Don")
End If
End Sub
///
I wish it were that easy, but pressing the tab key does not fire the
KeyUp/KeyDown/KeyPress events.
- Don
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:ez******** *****@TK2MSFTNG P14.phx.gbl... Don,
Is this not easier?
\\\ Private Sub TextBox1_KeyUp( ByVal sender As Object, _ ByVal e As System.Windows. Forms.KeyEventA rgs) _ Handles TextBox1.KeyUp If e.KeyData = Keys.Tab Then MessageBox.Show ("Hello Don") End If End Sub ///
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: aimee |
last post by:
Hi. Is there a way to capture the events fired in a PrintDialog? I
would like to capture when the user presses "Print" so I can do some
cleanup.
The asp.net (IE6) application I'm working on has 6 pages, each of
which has a link to a "print view" page. That "print view" page has a
"print" button which calls a javascript function "printThis":
function printThis() {
alert('printThis')
|
by: (Pete Cresswell) |
last post by:
I've got KeyDown coding and it fires when other keys are pressed, but when Enter
is pressed, nothing.
I'd like to support the (standard?) Windows behavior of executing DblClick
processing when an item is selected and the user presses Enter
I got focus to stop moving to the next control via Tools|Options|Keyboard|Move
after enter....but now it just sits there and neither KeyDown nor KeyPress seems
to catch it.
|
by: orekinbck |
last post by:
Hi There
In a C# windows app in .NET 2003, I would like to capture when the user
is within a certain text box and holds down shift then presses tab.
Atm, my code is:
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
const int WM_KEYDOWN = 0x100;
|
by: petedawn |
last post by:
guys,
i want to capture all the function key presses from F1 to F12. now i
want that when the user presses F1 from within the browser i should
display a alert window saying that they have pressed F1 instead of
displaying the browser help.
how can i implement this. thanks.
|
by: amiga500 |
last post by:
Hello,
I have one basic simple question. When I have multiple records in the
datagrid as follows:
Code Product 1 Product 2 Product 3
11111 A B C
22222 D E F
33333 G H I
44444 J K L
| |
by: trbjr |
last post by:
Hello experts,
I want to describe a project design and then ask some questions at the end.
There is no code in this discussion, just symbols to illustrate an idea.
Let S stand for a screen or form. I want to capture data as answers to questions presented to a user thru a series of screens. Since there are many user questions, I will ask them thru a series of screens. Thus, let
S1, S2, S3, ... Sn
|
by: xarzu |
last post by:
How do I capture the event in a CEdit control when the user presses enter or return in a dialog box? I have so far figured out how to disable the event when the user hits return which normally would close the dialog box (there are several ways to do this). This was only half of the problem. Now I am trying to capture the event inside the edit box.
|
by: sourav08 |
last post by:
Hello,
I'm developing a website using PHP, Javascript and MySQL.
I have a login form with a couple of textboxes and a login button. What I
want to do is capture the Enter key so that when the user presses Enter, it will behave like tab and throw the onchange event (written for each field).
I have searched the Internet for hours now trying to find out how to do it,
but any methods that I have seen do not work.
|
by: Vighneswar |
last post by:
Hi All
Can anybody please suggest me in this regard that I need to capture the
keystrokes on all the word processors (Ms Word, Excel .. Etc), text editors
(Notepad .. Etc) and suggest nearer words to the keystrokes. I have the DB
for suggesting the nearer words but wasn't sure on how to capture the
keystrokes on all the word processors, text editors.
Please advise. Thanking you in advance.
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |