Solved

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

Posted on 2004-04-15
5
768 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 

Author Comment

by:kamleshmistry
ID: 10833644
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
ID: 10833658
BY THE WAY, I AM WORKING WITH
    VB.NET     & not C#


0
 

Author Comment

by:kamleshmistry
ID: 10833727
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
ID: 10834229
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
ID: 10865433
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

A new era in Cloud training has arrived.

A day that will go down in Cloud history.. But are you ready for it? Will you accept this Cloud challenge?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

630 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