Solved

Need ascii for alt-x  for remap KeyPress in vb.net

Posted on 2004-04-15
5
737 Views
Last Modified: 2012-05-04
Does anybody have a web link for alt ascii characters for the purposes of remapping keypressed.

I am trying to re-map the enter key into an alt-x, so that when the user presses enter key after entering information into a text box in control xyz on form abc, the real key that gets pressed is alt-x.  Alt-x will cause a different button on the form to run its click method.  I can't call  MyButtonOnFormABC.Click within control xyz (I already thought about that) because as far as the control xyz is concerned, it has no knowledge about what other controls are on the form.  I could raise an event, but I'd rather just map enter key into an alt-x.  That sounds the easiest...



0
Comment
Question by:kamleshmistry
  • 4
5 Comments
 

Author Comment

by:kamleshmistry
Comment Utility
Furthermore, when processing keypress,
e.KeyChar seems to be read-only.

Is it not possible to re-map keys that are pressed to other keys?


0
 

Author Comment

by:kamleshmistry
Comment Utility
BY THE WAY, I AM WORKING WITH
    VB.NET     & not C#


0
 

Author Comment

by:kamleshmistry
Comment Utility
Actually re-mapping, if it were available, would be very useful, and I am quite surprized that e.KeyChar is read-only.  

One other scenario that I see re-mapping very useful is to remap the enter-key and make it equal to the tab, so that by pressing enter key, you can move to the next field...

I am going to increase the points for this question to 200

0
 
LVL 28

Accepted Solution

by:
iboutchkine earned 200 total points
Comment Utility
You can create procedure what you want to do on Alt-x. and then override Enter key to call this procedure

Override the ProcessDialogKey function at the form level, and see if the active control is the button and
the key pressed is Enter. Like this:

    Protected Overrides Function ProcessDialogKey(ByVal keyData As System.Windows.Forms.Keys) As Boolean
        If keyData = Keys.Enter Then
            'call procedure that wanted to call with alt-x
        End If
    End Function


Another trick that you can override the Enter key not for the whole application but only for some buttons
for example
    Protected Overrides Function ProcessDialogKey(ByVal keyData As System.Windows.Forms.Keys) As Boolean
        If Me.ActiveControl.Name = "btnSave" And keyData = Keys.Enter Then
            'the control is the button and the user has pressed Enter key, so handle this.
        End If
        'Otherwise, let the key be processed normally.
        Return MyBase.ProcessDialogKey(keyData)
    End Function

0
 

Author Comment

by:kamleshmistry
Comment Utility
Not helpful...
I am dealing with a control that has fields.
This control is within another form.
I have to be able to map the last textbox of the contol on the form... I have to re-map enter key ONLY for the last textbox on the control that is on the form....

Maybe there can be some type of if-checking....   if textbox abc on control xyz has focus and if you press enter then....

I don't know what that if statement might look like....
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now