This is a WinForms C# question.
I have a customized DataGridView control inherited from the standard DataGridView class. I want to monitor the case whenever a cell is added to the grid, a cell value is changed in the grid. I have no idea how to do this.
The DataBindingCompleted event is helpless in cell/row/column level. The CellValueChanged event is confusing itself since it is only fired when user modifies a value from UI and is helpless if the value is updated from underlying data source. What is the proper event to listen to?
I know DataGridViewCell class has a ValueChanging event. But in the customized DataGridView, how can I hook my event listener to every cell?
Thanks for the help.
1、You may inherit DataGridView when customized DataGridView.If inherit UserControl to customize DataGridView,you can not directly get CellValueChanged event when generate customized DataGridView in other project or application.
2、To do something in the CellValueChanged.
3、Inherit DataGridView implement.
(1) Create UserControl.Name is DataGridViewEx.
(2) Modify inherit.
public partial class DataGridViewEx : UserControl
==>public partial class DataGridViewEx :DataGridView
(3)Open DataGridViewEx.Designer.cs and shield //this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
.The sentence is in the method InitializeComponent().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With