Solved

Checkbox column in datagridview

Posted on 2006-11-22
2
923 Views
Last Modified: 2012-08-13
Hello everybody

I have a DataGridView in a C# windows app that I have populated using a DataTable. It works fine for the most part, except when I come to save any changes I have made.

The only editable column is a checkbox column.
When the program is running, if I tick several checkboxes in the column and then save, all the data is saved correctly with the exception of the last box ticked.

I think what's happeneing is that the DataTable used to populate the grid isn't updated when you click the checkbox until the checkbox/grid cell loses focus. I think somehow if I click save direclty after clicking the checkbox, my save methods are running before the DataTable is updated, and so the change is not picked up.

How can I get the DataGridView to update the DataTable as and when the checkboxes are clicked?
0
Comment
Question by:Rusty_Adams
2 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 17998874
Sounds like you have a pending edit:

   this.dataGridView1.EndEdit();

Bob
0
 

Author Comment

by:Rusty_Adams
ID: 18001443
Yep! That sorted it, cheers Bob!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

910 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now