简体   繁体   中英

DataGridView::CellBeginEdit event not firing

Using C# .NET 4.7.2 in Visual Studio 2019. Simple WinForms application with a DataGridView. After reading some data from a database, the data displays fine in the DataGridView.

After hooking up the CellBeginEdit event, the event handler is never fired. Tried a few other events, such as CellContentClick , CellEnter , CellClick , and all these events fire as normal.

I then added a second DataGridView control to the form, and displayed the data in this second grid. The CellBeginEdit event works as expected in the 2nd grid.

After reviewing settings for the original and new DataGridView controls in the Designer.cs file, nothing obvious explains the different behaviour.

What prevents CellBeginEdit from firing on a grid?

Oops, this is embarrassing. Turns out the ReadOnly property was set on the original DataGridView. I don't remember changing this property, but had changed MultiSelect which is just above ReadOnly in the Designer...possibly accidentally changed the setting at that time.

Will leave this here in case somebody else finds this useful.

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