简体   繁体   中英

Click Event not firing if it causes a CellEndEdit Event

I've a DataGridView where I'm showing some results that can be edited by the user, there's a save changes button that will update the database according with anything the user has input. I've checked that if I edit a record, make focus in another component and click the button changes are saved appropiately. Problem is that if I have a cell where the cursor is on, move directly to the save changes button and click it the only event that's fired is the CellEndEdit event, which would register there's a pending change, but it wouldn't update the database, opposite of what would be the expected behaviour, so the user would need to press the button again to do the changes.

Any idea on how to fire first the CellEndEdit and then the Click event in this situation so the result would be the expected one?

I finally got to solve it by checking on the CellEditEnd event if the save changes button is focused or not, if it is, I get to make all the save procedure, I think it should fire both events anyway, but as long as it works I don't care much.

Thanks for your tips, as they helped to guide me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM