473,699 Members | 2,612 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Catch Enter Key with KeyDown Event in Text Column of DataGridVIew Conrol

1 New Member
I want to catch Enter Key with KeyDown Event in TextColumn of DataGridView Control. When I press Enter in the txtItemCode column, I will check the ItemCode in the Database and other stuffs. I can get other keys but I can't get Enter. When I hit the Enter key, The focus is go to next row same column. How could I catch the Enter Key. I can catch with PreviewKeyDown Event but The Event occur from other columns also. I just want to catch from single column. I already googled but found nothing. Below is my code. Help me please.

Expand|Select|Wrap|Line Numbers
  1. Private Sub g_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles g.EditingControlShowing
  2.     Select Case g.CurrentCell.ColumnIndex
  3.         Case 0
  4.             Dim t As TextBox
  5.             t = e.Control
  6.             t.AcceptsReturn = False
  7.  
  8.             RemoveHandler t.KeyDown, AddressOf txt_KeyDown
  9.             AddHandler t.KeyDown, AddressOf txt_KeyDown
  10.     End Select
  11. End Sub
  12.  
  13. Private Sub txt_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
  14.     If e.KeyCode = Keys.Return Then
  15.         Dim t As TextBox = CType(sender, TextBox)
  16.         dtb = rst("select * from customer where customerno=" & Val(t.Text))
  17.         If Not dtb.Rows.Count = 0 Then
  18.             g.Rows(g.CurrentRow.Index).Cells(1).Value = dtb.Rows(0)("customername").ToString()
  19.         End If
  20.     End If
  21. End Sub
Oct 1 '13 #1
0 2226

Sign in to post your reply or Sign up for a free account.

Similar topics

1
3538
by: David | last post by:
I have a custom control that contains a class that Inherits the panel control. I am trying to catch a keydown event in this class and then supress it from the rest of the control as well as the form that hosts the control. The problem I am running into is that the form that hosts the control will respond to the keydown event event. Any ideas what I am missing? Some source code to help:
3
9227
by: bardo | last post by:
I have a Datagrid that is inside a panel. I want to use the keyDown event to reconize the arrow keys. But I have no luck at all. The problem is that the keydown event won't fire at all, unless I click on a row (withs will turn blue then) and then click on it again . Now if I press any key the event will fire (except for the arrow keys). I also tried to override the IsInputKey => no luck. I also tried to override the ProcessCmdKey => With...
3
3280
by: trint | last post by:
Ok, I have tried to do this with the System.Web.UI and can't find anything for the webform. It seems much easier for a Winform. Any help in trapping Webform keydown event and keyup event is appreciated. Thanks, Trint
2
1916
by: Helen Trim | last post by:
I am struggling to get the keydown event for checkboxes to work when pressing down arrow and enter. The so-called help talks about overriding the IsInputKey method for the controls, but doesn't give an example. How do I override a control's method? TIA -- Helen
1
5860
by: dana1 | last post by:
I have a form with several combo boxes in the header used to determine the records that will be displayed on the form. When I tab or enter from the last combo box in the header, I want the focus to move to the first control on the form. When I Shift+tab from the first control on the form, I want the focus to move to the last control in the header. The form is a continuous form. The first control on the form is either a text box or a combo...
1
4759
by: kgerritsen | last post by:
I am building an application that will receive input from a barcode scanner. The barcode scanner is configured to append to the front value a single character and hyphen that identify the barcode standard, then the value in the barcode, terminated by a return. The barcode scanner appears to the operating system as a USB keyboard. I am loading the barcode value into a textbox both on my Form1 and on a dialog box where the user has to...
9
4056
by: pvsundarram | last post by:
hey, i am trying to cancel the keydown event for certain keycodes( for eg:- enter key ).But the cancelling of this event is not happening in firefox. Is there any way to cancel the event in the iframe. CODE ===== <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en_US"
3
5450
by: M K | last post by:
My dg is loaded (from stored procedure) and has 1 record in it. When I press enter on that row it does nothing (I have a breakpoint just inside the code where i check for enter pressed) if (e.KeyData == Keys.Enter) It never goes into that event. For the DataGridView I have: ReadOnly = false
2
2808
by: lenniekuah | last post by:
Hi Friends, Encounter another interesting problem of practical event. I have used FORM KEYDOWN event to navigate the cursor and on the Primary Key TextBox I tried to validate the input after ENTER was pressed it does not work. Here are the coding private void FrmCustomerRef_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Escape) { this.Close();
3
6314
maheshwag
by: maheshwag | last post by:
I have a databound combobox column on DGV I am trying to fire a keys on keydown eventhandller on DGV as below: private void Form1_Load(object sender, EventArgs e) { string connstr = "server=.;initial catalog=maa;uid=mah;pwd=mah"; SqlConnection con = new SqlConnection(connstr); con.Open(); string sql = "select name from dummy"; SqlDataAdapter dap = new...
0
8705
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9197
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
9054
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...
0
8897
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7785
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
6549
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
4390
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3071
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2362
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.