问题标签 [eventargs]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
1186 浏览

c# - 为什么对 EventHandler 没有限制?

我只是偶然发现(当编译的东西我认为不会编译时)EventHandler不受类型 System.EventArgs 的限制。

这是内联文档:

这是文档和实现之间的不匹配吗?

我问是因为我很好奇。这根本不是抱怨。

0 投票
1 回答
405 浏览

c# - 如何在计时器中使用 MouseEventArgs?

它不起作用 我该怎么做?

0 投票
2 回答
894 浏览

c# - 带有 FormClosingEventArgs 的 EventHandler

我的 Form.cs 中有这个结束表单代码

以及我的 Form.designer.cs 中的这段代码

但是它一直显示错误“'label7_Click'没有重载匹配委托'System.EventHandler'”

我应该怎么办?

0 投票
1 回答
1433 浏览

c# - EventArgs.Empty 澄清?

我有一个方法

我希望其他代码调用此方法。(并不真的需要sendere

就像是 :

Item_Click(null, null)

但后来我记得我可以EventArgs.Empty改用。

鼠标悬停在上面显示:

在此处输入图像描述

等等……什么?

EventArgs.Empty 代表一个事件?它不是。它应该代表空论点而不是事件。

就像string.empty代表空字符串一样。

  • 我在这里错过了什么吗?
0 投票
3 回答
7606 浏览

c# - 通过 Sender c# 从动态 NumericUpDown 获取值

我遇到了一个非常烦人的问题。

我有这些全局变量(用于保留名称等)

之后我有一个函数可以生成 NumericUpDowns,具体取决于数据库中的记录数。该函数如下所示:

最后,我想在用户更改 numericUpDown 时更新记录(通过单击 numericupdown 或更改数字)

但是每次我运行这个我都会遇到同样的问题..“无法将对象从 System.Windows.Forms.Button 类型转换为 System.Windows.Forms.NumericUpDown 类型”

如何解决此问题并根据 NumericUpDown 上填写的新数字更新记录?我无法正常工作,我感觉这与发件人的工作不正常有关..

感谢所有的帮助!延特

0 投票
3 回答
3978 浏览

c# - 带有 FormClosingEventArgs 的 EventHandler - C#

我的 Form.cs 中有这个结束表单代码

以及我的 Form.designer.cs 中的这段代码

但是它一直显示错误

“'label7_Click' 没有重载匹配委托 'System.EventHandler'”

我该怎么办?

0 投票
1 回答
143 浏览

c# - 为什么微软在连接事件时使用新的 EventHandler

假设我有一个记录错误的类(ErrorLog)。每次将错误添加到日志时,该类都会引发一个事件 (ErrorLog.EventErrorAdded) 以通知观察者日志中添加了新错误。此事件有一些数据 (ErrorLog.EventErrorAddadArgs)。

另一个班级想要观察这些事件。构造函数订阅 ErrorLog.EventErrorAdded 以便调用方法 OnEventErrorAdded(object Sender, ErrorLog.EventErrorAddedArgs Args)。

我发现 Microsoft 订阅该事件的方式与我的订阅方式之间存在差异。这两种方法似乎都有效。我不明白微软方法的优势。有谁会?

代码将类似于:

这两种方法都在编译时检查语法正确性。两种方法都有效。所以我的问题是:在我只提到委托函数的方法之上的“新 System.EventHandler”方法有什么优势?

0 投票
2 回答
1415 浏览

c# - C# 事件参数传递

好的,所以我有一个关于在触发事件时可以传递的 EventArgs 的问题。我正在设计一个小型的基本搜索引擎,并有一个名为 Query 的类,其中包含一个方法 Search。调用此方法时,我想触发一个事件,该事件将传递结果以存储在各种缓存类实例(SizeBoundedCache 和 TimeBoundedCache)中。所以我认为最好的方法是使用一个事件。

委托是这样声明的->

Query 类中与此问题相关的其余代码在这里(使用 Linq)->

每当调用搜索时,都会通知所有缓存类,我还需要接收结果。

非常感谢您的帮助。另外,如果有一种我没有想到的更优雅的方式来做到这一点,请加入。干杯!

0 投票
1 回答
693 浏览

c# - 如何使用 binaryFormatter 在 c# 中序列化 EventArgs

我有一个表单,我需要保存对控件表单所做的操作。为此,我有这样的事情:

我需要序列化,但不能序列化EventArgs,因为事件可以是键盘鼠标,这是表单上可以发生的各种事件。

这样做的目的,是制作一个记录器,它记录在表格上采取的所有动作。

0 投票
1 回答
185 浏览

.net - when we need to pass nullptr to an object^ or EventArgs ? and why to pass EventArgs::Empty to EventArgs^?

I have a method in my code, it's name is bindingSource_PositionChanged. the definition of it is:

#xA;

My questions:

  1. I have in my program calling the function in this way:

    #xA;

    my Question 1: what makes pass System::EventArgs::Empty to the parameter e of this function? or to any System::EventArgs^. and what makes pass nullptr to the parameter sender here? or to any System::Object^ sender?

  2. I have in my program calling the function in another way:

    #xA;

    Question 2: what makes a nullptr to the parameter e of this function? or to any parameter of the type System::EventArgs^?