开发者

Simulate a DataGridView.DataChanged event?

开发者 https://www.devze.com 2023-01-21 00:42 出处:网络
I want to make a single event that will capture every change in the data in a DataGridView. The list of events is pretty long. I was thinking I could bind the DataGridView to a DataTable since it has

I want to make a single event that will capture every change in the data in a DataGridView. The list of events is pretty long. I was thinking I could bind the DataGridView to a DataTable since it has less events and it gets notified whenever the user changes the data in the DataGridView. Since the amount of data is tiny (2 columns and about 5 rows) but the user should be able to add, remove and edit rows, it would be a lot simpler if I put all possible changes in a single event so every other class that needs it gets notified when anything changes in the DataGridView's data by handing a single event. I don't want to capture when the user is typing in a cell or when a row is resized or anything that won't be normally considered as representing a change in the data. That's also why I think using a binded DataTable is a good idea. So my question is, which set of events is the minimum I need to handle in order to capture every possible 开发者_StackOverflowchange in the data contained in a DataGridView or in a DataTable (preferably a DataTable I think)?


I would try to bind to the following DataTable events:

  • RowDeleted
  • RowChanged

Those should give you what you want - notification only in case you edit, delete or add a row.

0

精彩评论

暂无评论...
验证码 换一张
取 消