I have a 2 column DGV. When a user enters a value in cell 0,0 I want to set
cell 0,1 as current, when they enter a value in cell 0,1 I want to set cell
1,0 current, etc, etc
basically zig-zagging down the rows from left to right.
I'm calling this method below in my CellEndEdit event:
private void AdvanceCellFocus(DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 0)
{
dataGridView_SerialNumberLinks.CurrentCell =
dataGridView_SerialNumberLinks[e.ColumnIndex + 1, e.RowIndex];
}
else
{
if (e.RowIndex < dataGridView_SerialNumberLinks.Rows.Count)
{
dataGridView_SerialNumberLinks.CurrentCell =
dataGridView_SerialNumberLinks[e.ColumnIndex - 1, e.RowIndex
+ 1];
}
}
}
The result is this:
- Data entered into cell 0,0
- AdvanceCellFocus() called and sets cell 0,1 as current
- when control returns to the UI, cell 1,1 is current.
So the problem appears to be that the default behavior of advancing a row
upon completing an edit operation is still happening. I'm not finding a way
to deal with it.
Anyone have any ideas? Suggestions?
Thanks for reading,
Steve 2 4558
I found this while googling: http://forums.microsoft.com/MSDN/Sho...27470&SiteID=1
Basically suggest suppressing the enter key event, but that will also
prevent EditMode from committing and saving the data.
I think my new, refined question is: How to prevent DGV from advancing to
next row when 'entering' out of edit mode?
"sklett" <s@s.comwrote in message
news:eU**************@TK2MSFTNGP04.phx.gbl...
>I have a 2 column DGV. When a user enters a value in cell 0,0 I want to set cell 0,1 as current, when they enter a value in cell 0,1 I want to set cell 1,0 current, etc, etc
basically zig-zagging down the rows from left to right.
I'm calling this method below in my CellEndEdit event:
private void AdvanceCellFocus(DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 0)
{
dataGridView_SerialNumberLinks.CurrentCell =
dataGridView_SerialNumberLinks[e.ColumnIndex + 1, e.RowIndex];
}
else
{
if (e.RowIndex < dataGridView_SerialNumberLinks.Rows.Count)
{
dataGridView_SerialNumberLinks.CurrentCell =
dataGridView_SerialNumberLinks[e.ColumnIndex - 1,
e.RowIndex + 1];
}
}
}
The result is this:
- Data entered into cell 0,0
- AdvanceCellFocus() called and sets cell 0,1 as current
- when control returns to the UI, cell 1,1 is current.
So the problem appears to be that the default behavior of advancing a row
upon completing an edit operation is still happening. I'm not finding a
way to deal with it.
Anyone have any ideas? Suggestions?
Thanks for reading,
Steve
I found the solution. I needed to subclass the DGV to get to the key events
when in edit mode.
"sklett" <s@s.comwrote in message
news:uK**************@TK2MSFTNGP05.phx.gbl...
>I found this while googling: http://forums.microsoft.com/MSDN/Sho...27470&SiteID=1
Basically suggest suppressing the enter key event, but that will also
prevent EditMode from committing and saving the data.
I think my new, refined question is: How to prevent DGV from advancing to
next row when 'entering' out of edit mode?
"sklett" <s@s.comwrote in message
news:eU**************@TK2MSFTNGP04.phx.gbl...
>>I have a 2 column DGV. When a user enters a value in cell 0,0 I want to set cell 0,1 as current, when they enter a value in cell 0,1 I want to set cell 1,0 current, etc, etc
basically zig-zagging down the rows from left to right. I'm calling this method below in my CellEndEdit event: private void AdvanceCellFocus(DataGridViewCellEventArgs e) { if (e.ColumnIndex == 0) { dataGridView_SerialNumberLinks.CurrentCell = dataGridView_SerialNumberLinks[e.ColumnIndex + 1, e.RowIndex]; } else { if (e.RowIndex < dataGridView_SerialNumberLinks.Rows.Count) { dataGridView_SerialNumberLinks.CurrentCell = dataGridView_SerialNumberLinks[e.ColumnIndex - 1, e.RowIndex + 1]; } } }
The result is this: - Data entered into cell 0,0 - AdvanceCellFocus() called and sets cell 0,1 as current - when control returns to the UI, cell 1,1 is current.
So the problem appears to be that the default behavior of advancing a row upon completing an edit operation is still happening. I'm not finding a way to deal with it.
Anyone have any ideas? Suggestions?
Thanks for reading, Steve This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dominic |
last post by:
Hi guys,
I'm not sure if this question belongs to FAQ, but I couldn't find a
concrete answer.
I created a Datagrid control using ItemTemplate, but it's NOT a
in-place editing datagrid. One of...
|
by: melanieab |
last post by:
Hi,
I have a datagrid & a datatable, and when I use the mousemove event, I run
into trouble.
private void dgMouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{...
|
by: Bob |
last post by:
In a datagridview (vs2005, VB.net) I have two columns that are checkboxes. I
need to check that only one of the two can be checked. Its not permissible
to have the two selected to true, but they...
|
by: Elmo Watson |
last post by:
I previously had a project working, in which the Gridview was populated by a
DataSet - then, with a DropDownlist in one of the columns, using the
OnrowDataBound event, to populate the DDL with the...
|
by: Lennart Nielsen |
last post by:
I can find the X and Y (column/row) coordinates, but not the actual location
(Left,Top) positions.
Any ideas?
Lennart
| |
by: Paul |
last post by:
Hello All,
I have been trying to figure out how to set the BackColor of
individual cells in a DataGridView. I found the following solution in
a VB usenet group
DataGridView1.Item(ColumnIndex,...
|
by: QuickBooksDev |
last post by:
VB.NET 2005 DataGridView Checkbox - Check Event need to know check status
I would like to use the DataGridView Checkbox like a normal checkbox.
When someone clicks on it I would expect that I...
|
by: systeko |
last post by:
Hello,
I have one little problem which make me crazy. I've made application (for Windows) in Visual C#. On one panel I've got datagridview control which is not bind to database, I populate it...
|
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...
|
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,...
|
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,...
| |
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...
|
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...
|
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: 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,...
|
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...
|
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 ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |