如何在Datagridview中的C#Datatable中的Update上引发CellValueChange事件c# [英] How to Raise CellValueChange event on Update in C# Datatable in Datagridview c#

查看:290
本文介绍了如何在Datagridview中的C#Datatable中的Update上引发CellValueChange事件c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在DataGridView中触发CellValueChange事件,直接在datatable中更新是一个

Grid的数据源,如果我们手动设置单元格中的值,它是否直接工作。我也尝试过CellFormating事件,但它只适用于可见细胞。



任何帮助将不胜感激

I need to fire CellValueChange Event in DataGridView when directly update in datatable is a
DataSource of Grid whether it's working directly if we have set value in cell manually. I have tried with CellFormating event also but it's working only for visible cells.

Any help will be greatly appreciated

推荐答案

可能你不明白一些非常基本和基本的东西。除非事件实例在要调用它的同一个类中声明,否则不能直接引发事件;即使在派生类中也无法调用事件。由于类 DataGridView 是来自.NET FCL的代码,因此根本无法调用该事件。这是.NET的一个非常重要的傻瓜式功能。你永远不需要调用那些事件;他们不是为此而设计的。您只能处理该事件。当你真正改变任何单元格的内容时,会在这个类中调用even,但这不是问题,对吧? :-)

-SA
Probably you don't understand something very basic and fundamental. You cannot directly "raise event", unless the event instance is declared in the same class where you want to invoke it; you cannot invoke an event even in a derived class. As the class DataGridView is the code from .NET FCL, you cannot invoke that event at all. This is a very important fool-proof feature of .NET. You never really need to invoke those events; they are no designed for that. You can only handle the event. The even will be invoked in this class when you actually change the content of any cell, but that cannot be a problem, right? :-)
—SA


这篇关于如何在Datagridview中的C#Datatable中的Update上引发CellValueChange事件c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆