Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > .NET 1.0 and Visual Studio.NET > .NET Framework 1.x
|
.NET Framework 1.x For discussing versions 1.0 and 1.1 of the Microsoft .NET Framework.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 1.x section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 28th, 2007, 04:43 AM
Authorized User
 
Join Date: Aug 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default capture return key in keydown event

i have a datagrid and everytime the focus of the cursor on one of the cells and i press enter/return key, i want to emerge a modal form. but it seems that enter key doesn't raise the keydown/keypress/keyup event. the msdn provides information like this:

"Certain keys, such as the TAB, RETURN, ESCAPE, and arrow keys are handled by controls automatically. In order to have these keys raise the KeyDown event, you must override the IsInputKey method in each control on your form. The code for the override of the IsInputKey would need to determine if one of the special keys is pressed and return a value of true"

but it doesnt provide me with the example how to do that. please
anybody can show me how to make use this isinputkey method

thanks in advance,
albert

 
Old April 23rd, 2007, 11:21 AM
Authorized User
 
Join Date: Oct 2005
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can manually capture the Enter key using javascript, and here's an example:

function keyDownHandler(buttonId) {
    // Process only the Enter key
    if (event.keyCode == 13) {
        // cancel the default submit
        event.returnValue = false;
        event.cancel = true;

        if (document.getElementById(buttonId))
            document.getElementById(buttonId).click();
    }
}

SQL Server Helper
How well do you know SQL? Find out with the free test assessment from SQL Server Helper!!!
http://www.sql-server-helper.com/free-test/default.aspx

Got a SQL Server Question? Ask us here: http://www.sql-server-helper.com/forums/default.asp





Similar Threads
Thread Thread Starter Forum Replies Last Post
DatagridView Keydown Event senpark15 C# 0 June 28th, 2008 12:34 AM
TAB KEY working together KEY PRESS event thomaz C# 4 August 20th, 2006 02:47 PM
Hi,HuhOic.(How to use keydown event) zhangxujun1981 C# 1 September 20th, 2004 07:17 PM
How to use KeyDown event in Form zhangxujun1981 C# 5 July 6th, 2004 02:07 AM
About Button event and Keydown event zhangxujun1981 XSLT 1 March 6th, 2004 04:59 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.