Solved

Completing cell edit in DataGridView

Posted on 2010-11-14
4
731 Views
Last Modified: 2012-05-10
I'm using c# 4.0. I have a DataGridView on a form.

When the data changes (via CellValueChanged), a Save button is enabled that lets the user save, after which the button is disabled.

However, the user can type something into a cell but leave the cursor in the cell; effectively not committing the cell (CellValueChanged does not fire). Is there some way I can shift the mode from cell editing so that the value is committed when Save is clicked?
0
Comment
Question by:BlearyEye
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 500 total points
ID: 34133722
You can try calling the EndEdit() method of the DataGridView upon leaving a cell.
private void dataGridView1_CellLeave(object sender, DataGridViewCellEventArgs e)
{
    this.dataGridView1.EndEdit();
}

Open in new window

0
 
LVL 1

Accepted Solution

by:
BlearyEye earned 0 total points
ID: 34134365
That pointed me in the right direction. Just doing the EndEdit() resulted in losing the changes. I had to end the edit on the current row, then the data grid, then the binding source.

this.DataGridView1.CurrentRow.DataGridView.EndEdit();
this.DataGridView1.EndEdit();
bindingSource1.EndEdit();
taDevices.Update(tblDevices1.devices);

Open in new window


See disucssion at http://social.msdn.microsoft.com/forums/en-US/winformsdatacontrols/thread/f9b92a39-2c7d-4c33-b89d-8d58e391eb6a/
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 34135849
Cool, glad you found an answer  :)
0
 
LVL 1

Author Closing Comment

by:BlearyEye
ID: 34182351
It pointed me in the right direction but needed more
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question