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
Solved

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

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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

856 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