Solved

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

Posted on 2004-04-15
5
743 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
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

816 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

12 Experts available now in Live!

Get 1:1 Help Now