简体   繁体   中英

How to suppress row change after cell edit in c# dataGridView?

After changing value in cell and pressing enter cursor jumps down to next cell. Is it possible to avoid this behavior? I want to make cursor stay at same cell after edition accomplishment. I use CellEndEdit to perform some action with value in cell.
Thanks!

您可以通过按keypress事件或cellvaluechanged事件找到enter键来限制它

After all I solved my problem in following lame way.
1. Add global boolean flag to detect if I need to jump up after edit and set it to false .
2. In CellEndEdit event handler set flag to true .
3. In SelectionChanged event handler check flag. If it set to true then jump up and set flag to false .
4. Set AllowUserToAddRows to false to avoid adding row in case of last row cell edition.

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