Solved

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

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

Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

Question has a verified solution.

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

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

734 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