473,796 Members | 2,640 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Enter Event + Shortcut

Hi, i want to ask view questions
1.when i press Enter button on the textbox
how do i trigger an event?

2.How do i use shortcut key for example ctrl+s to call
certain function.
Nov 16 '05 #1
1 4929
Hi Kimochi,

1. Capture the TextBox's KeyUp event and raise the event if the KeyCode is
Enter, something like this:

// Called from constructor
// EnterEvent += new EventHandler(En terEventHandler );

private void textBox2_KeyUp( object sender,
System.Windows. Forms.KeyEventA rgs e)
{
if (e.KeyCode == Keys.Enter)
{
EnterEvent(this , EventArgs.Empty );
}
}

public event EventHandler EnterEvent;

private void EnterEventHandl er(object sender, EventArgs e)
{
MessageBox.Show ("You pressed the enter key in textBox2!");
}

2. You can add a menu with a menu item that has it's Shortcut property set
to CtrlS.

Joe
--
http://www.csharp-station.com

"Kimochi" <an*******@disc ussions.microso ft.com> wrote in message
news:06******** *************** *****@phx.gbl.. .
Hi, i want to ask view questions
1.when i press Enter button on the textbox
how do i trigger an event?

2.How do i use shortcut key for example ctrl+s to call
certain function.

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
15640
by: bullshark | last post by:
VSN03:C# Create a C# Windows Form project. Add two TextBox controls. From the Properties of each, add an Enter Event handler. In the generated Enter Event Handlers (textBox1_Enter & textBox2_Enter ), add the code TextBox1.SelectAll(); and TextBox2.SelectAll(); Run the App. When you run the app with a breakpoint at textBox1_Enter(), and
0
3558
by: Ollie | last post by:
When a form has a default button (Form.AcceptButton) and\or a shortcut key for that button (e.g. "&Process") and this button happens to close the form when clicked. Why does the control that currently has focus (e.g. TextBox) recieve TWO 'OnValidating' events when the shortcut key is activated or the default button is triggered by pressing the "Enter" key. Is this a feature of .Net?
4
1366
by: Sam | last post by:
Hi, This is driving me totally insane. I have two datagrid controls, and when I click on the first one its Enter event is called properly but the Enter event of the other one is being called straight after. I don't understand why... Here is my code if someone wants to have a look at that: Private Sub dgCtrl_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgCtrl.Enter m_dgCtrlFocused = True
1
1085
by: theinvisibleGhost | last post by:
Is there an underlying interface anywhere that .NET form controls use to include the Enter, Leave, GotFocus, and LostFocus events? I have a problem where I've got a usercontrol which is being used in a Media Player Plugin. The plugin offers C# Scripting capabilities through an Open Source Scripting engine. I want to detect if scripts have been changed by another program.
0
1247
by: jamcompany via AccessMonster.com | last post by:
I have set up speed testing. I noticed that the majority of the time to load the login form (the form listed in my startup) is between the Form's Current event and the first control's Enter event. It's between 1 - 6 seconds between the two, which is by far the most time intesive part of the startup process. Are there any events that come between these two? I thought they were connected, and would be nearly simultaneous. I checked the...
2
8082
by: ozarka | last post by:
I have a search form. and many unbound control. My main search text box "txtAccount" is acting weird or I am not doing it right. I want user to input a value and hit the enter key. I put something on the "on Enter" event but the code kicks in as soon as I load the form. After by passing the first error I enter something in my search box and hit the enter key on my keyboard and nothing happens. I even try to put msgbox "test" on the enter...
1
5208
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hello I've created a .NET 2.0 form and added 6 text boxes, 1 combo box and 2 button controls. The combo box has a DropDownStyle of DropDown, so the user can still type in the combo box. The combo box has the follows values in it's drop down list: "Dear Sir,"
0
1125
by: Rainer Queck | last post by:
Hello NG, the hint on the property editor for the Form "Enter" event sais: Gets fired, if this control gets the active control. In my application I experience, that this is "mostly" true, but some times not. I have a MDI application, and I use the <Form>.BringToFront() to activate a hidden window. Usually I get the "Enter" event on doing this. But I just had the case, that this event didn't get fired anymore. I
4
14023
by: ronakinuk | last post by:
hello i need help in this please. i dont have much knowledge of VBA but can do very basic things by learning from different forums. i want to create one excel application where there will be few userforms. and on each there will be some text boxes. i want it to work like this. if user puts number 2 in textbox1 on userform1 and then PRESS ENTER, unload userform1 and show userform2, but if user puts 3 in textbox1 on userform1 and PRESS...
0
9525
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10452
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10221
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10169
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9050
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7546
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6785
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5569
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.