Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > how to leave from a cell when save the data in the datagridview
 

how to leave from a cell when save the data in the datagridview

Ifill the datagridview,and i need to validateeach data that i fill in.I use the CellEndEdit event to validate each data.Then i click a button to save those data.But i have a problemTongue Tiedome user may fill some cells,and they may not leave the last cell

and click the button.so the last cell doesn't happen CellEndEdit event ,and the last data that fill in cannot be validate.This may lead to an error when i save because the illegal data.

I want to ask:how to slove this problem,is there any way that i can leave from the last cell and let CellEndEdit event happen then save or i must validate the date in the click event ,i hope i can come true the first scheme.

my english is poor,thanks.

lerit_liu  Thursday, April 03, 2008 1:34 PM

Hi

It's better to handle the CellValidating event instead of the CellEndEdit event for validating. And you can call the DataGridView.EndEdit() method in theclick event handler function of the save buttonto force the DataGridView to finish the editing.

Best Regards

Zhi-xin Ye

Zhi-Xin Ye  Wednesday, April 09, 2008 3:15 AM

hi,

i got that problem before, i was working on spreadsheets program to be loaded in the gridview and have user edit from there. i was not able to resolve the issue but have an internal arrangement with all the users to press tab to make the changes. just advice your user to do the same of what i did.

Bermil M. Espina  Thursday, April 03, 2008 1:40 PM

thanks for your reply,but mayby i cannot tell every user to do so.

I hope i can slove it myself

lerit_liu  Thursday, April 03, 2008 1:46 PM

Hi

It's better to handle the CellValidating event instead of the CellEndEdit event for validating. And you can call the DataGridView.EndEdit() method in theclick event handler function of the save buttonto force the DataGridView to finish the editing.

Best Regards

Zhi-xin Ye

Zhi-Xin Ye  Wednesday, April 09, 2008 3:15 AM

You can use google to search for other answers

Custom Search

More Threads

• Populating combo boxes on a usercontrol issue
• Datasets created with VS2005 IDE do not fetch Child data
• Having trouble databinding a textbox to display results from a search
• (Should be a simple) BindingSource question
• how to create a new DataGridViewCellValidatingEventArgs object
• fill data in combobox
• RowState changed by just traverse table in DataGridView
• DataGridView column valuetype to bitmap.
• How I do to Edit a DataGrid (Vs 2003 Framework 1) ?
• Unbound 600 x 20 DataGridView displaying 50 cols x 13 rows, horizontal scrolling is slow and jerky