VB.NET - Can someone help me with this Keypress Problem?

Asked By Mike Smith on 09-Mar-05 02:57 PM
Even though this forum is supposed to be for advanced .Net Developers I an striving to become one so I figured I would register.

I am trying to attach a Keypress to a textbox and have the Keypress be the "Enter" key as well as a few "F?" Can someone tell me how to code the "Enter" key into the Keypress Event?

Is this a web app or a windows app? - Asked By Robbe Morris on 09-Mar-05 03:23 PM

.

It is a wondows app - Asked By Mike Smith on 09-Mar-05 03:26 PM

It is a Windows App. OT: I sent you an email, hope you dont mind.

Look at the Property sheet for your control - Asked By Peter Bromberg on 09-Mar-05 04:09 PM

and press the yellow lightning bolt symbol to see the events.

Double click in the KeyPress event row to expose a stub for the handler and add the delegate code.

Inside the handler, you can do stuff like:

if(e.KeyChar == (char)13)
            e.Handled=true;
tried that - Asked By Mike Smith on 09-Mar-05 04:15 PM
I am in the event, and can make the keypress event work. the problem I am having is assigning the keypress directly to the enter key. What I am trying to do is enter char into a textbox and then when I hit enter make it go to another plugin window.
I must be "not getting it" - Asked By Peter Bromberg on 09-Mar-05 09:41 PM
if you do this:

private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
		{
			if(e.KeyChar == (char)13) 
				 // do whatever you need to do right here
		}

you can do whatever you want in the comment line. All other characters will be accepted normally. What are we missing?
Can someone help me with this Keypress Problem? - Asked By Jeffery Riegel on 11-Mar-05 11:02 PM
Here's a c# example using the keyUp In your case use Keys.Enter

private void DCRAcessLvlMgmt_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
{
	if((e.Control == true) & (e.Alt == true) & (e.KeyCode == Keys.P))
	{
	     // Control Alt P sets the string
	     string x = "jfj";
	}
}