473,396 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Treating Enter key on DataGridView

Hi all!

I have a special treatment to Enter key in a datagridview . When Enter key
is pressed I move to the next column on the row. Here is the code:

private void dgv_EditingControlShowing(object sender,
DataGridViewEditingControlShowingEventArgs e)
{
e.Control.KeyPress -= new
System.Windows.Forms.KeyPressEventHandler(this.Tex tbox_KeyPress);
e.Control.KeyPress += new
System.Windows.Forms.KeyPressEventHandler(this.Tex tbox_KeyPress);
}

private void Textbox_KeyPress(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
if ( dgv.ColumnIndex + 1 < dgv.Columns.Count )
{
== dgv.CurrentCell =
dgv.Rows[dgv.CurrentCell.RowIndex].Cells[dgv.CurrentCell.ColumnIndex + 1];
e.Handled = true;
}
}
}

When the line marked with "==>" is executed, the dgv_CellValidating() event
is called and if I set "e.Cancel = true;" gives me the following error:

"Operation did not succeed because the program cannot commit or quit a cell
value change".
So, how can I call dgv_CellValidating() before moving to the next cell?

Thank you!
Vanessa
Jun 27 '08 #1
0 1583

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

Similar topics

3
by: Rich | last post by:
Hello, I am populating a datagridview from a datatable and filtering the number of rows with a dataview object. Is there a way to retrieve the rows displayed by the datagridview into a separate...
7
by: Mitchell S. Honnert | last post by:
Is there an equivalent of the DataGrid's DataGridTableStyle for the DataGridView? If not, is there an easy way to duplicate the DataGridTableStyle's functionality for the DataGridView? Here's...
1
by: Scotty | last post by:
Hi, I am struggling with folowing problem, I am a beginner of vbnet 2005 I have a datagridview and want to use ENTER key to move instead of the TAB key. On msdn i have found the code to...
7
by: =?Utf-8?B?TG9zdEluTUQ=?= | last post by:
Hi All :) I'm converting VB6 using True DBGrid Pro 8.0 to VB2005 using DataGridView. True DBGrid has a MultipleLines property that controls whether individual records span multiple lines. Is...
0
by: jeastman - Hotmail | last post by:
Hello world Excuse, not to be written English and it helps me with a translator. I am new programming in C#. I made a control inheriting the DataGridView to be able to add controls done by...
0
by: nithyamca | last post by:
Hi.. I want to use enter key to move the next column in datagrid view in vb.net and when ever press the enter key in last cell in grid it create the next row . actually i am hide some cells in...
0
by: nithyamca | last post by:
Hi I want change the process of key events in datagridview in vb.net .. now enter key is press in datagridview it move to next row but i want to stop this process pls help me
1
by: anoopanand | last post by:
hii again, im using datagridview for entering datas. Enter key used to navigate from one column to another but i cant navigate the cursor from datagridview's one cloumn to anthoer with single...
3
by: Andrus | last post by:
I have DataGridView in virtual mode containing 3500 rows. In code below, assigning to RowCount value to 3500 takes 8 seconds. CPU usage goes high at this time. Stepping by F11 into user code shows...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
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...

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.