设置NumericUpDown.Value属性时不会触发ValueChanged事件 [英] ValueChanged event NOT being fired when setting NumericUpDown.Value property
问题描述
我正在设置NumericUpDown .Value属性和ValueChanged事件
未被触发。当我在UI上更改它时,这只会被解雇吗?
不是以编程方式进行的吗?
谢谢
Hi,
I am setting the NumericUpDown .Value property and the ValueChanged event
is NOT being fired. Does this ONLY get fired when I change it on the UI and
not programatically?
Thanks
推荐答案
< di ******** @ discussion.microsoft.com>写道:
<di********@discussion.microsoft.com> wrote:
我正在设置NumericUpDown .Value属性,并且没有触发ValueChanged事件
。当我在UI上更改它并且不以编程方式进行时,这只会被解雇吗?
I am setting the NumericUpDown .Value property and the ValueChanged event
is NOT being fired. Does this ONLY get fired when I change it on the UI and
not programatically?
我没有看到你所描述的行为。例如:
使用System;
使用System.Windows.Forms;
class Test
{
static void Main()
{
NumericUpDown nud = new NumericUpDown();
nud.ValueChanged + = new EventHandler(SayHello);
nud.Value = 20m;
}
static void SayHello(object sender,EventArgs e)
{
Console.WriteLine(" Hello");
}
}
显示Hello正如预期的那样。
你能否制作一个类似的简短但完整的程序
演示了这个问题?
- -
Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet
如果回复群组,请不要给我发邮件
I''m not seeing the behaviour you''ve described. For instance:
using System;
using System.Windows.Forms;
class Test
{
static void Main()
{
NumericUpDown nud = new NumericUpDown();
nud.ValueChanged += new EventHandler (SayHello);
nud.Value = 20m;
}
static void SayHello (object sender, EventArgs e)
{
Console.WriteLine ("Hello");
}
}
displays "Hello" as expected.
Could you produce a similar short but complete program which
demonstrates the problem?
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
我在PANEL中有控件并且它的Panel.Enabled = false,然后当它处于false状态时我更新了NumericUpDown.Value属性及其
没有开火。是否仅在启用容器中时触发?
Jon Skeet [C#MVP]" < SK *** @ pobox.com>在消息中写道
新闻:MP ************************ @ msnews.microsoft.c om ...
I have the control in a PANEL and its got Panel.Enabled = false, then while
its in the false state I update the NumericUpDown.Value property and its
not firing. Does it only fire when its in an Enabled container?
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
< di ******** @ discussion.microsoft.com>写道:
<di********@discussion.microsoft.com> wrote:
我正在设置NumericUpDown .Value属性,并且没有触发ValueChanged
事件。当我在UI
而不是以编程方式更改它时,这只会被解雇吗?
I am setting the NumericUpDown .Value property and the ValueChanged event is NOT being fired. Does this ONLY get fired when I change it on the UI and not programatically?
我没有看到你所描述的行为。例如:
使用System;
使用System.Windows.Forms;
类测试
{
静态无效Main()
{NumericUpDown nud = new NumericUpDown();
nud.ValueChanged + = new EventHandler(SayHello);
nud.Value = 20m;
}
static void SayHello(object sender,EventArgs e)
{
Console.WriteLine(" Hello");
}
} >
显示你好正如预期的那样。
你能否制作一个类似的简短但完整的程序来展示这个问题?
-
Jon Skeet - < sk * **@pobox.com>
http://www.pobox.com/ 〜双向飞碟
如果回复小组,请不要给我发邮件
I''m not seeing the behaviour you''ve described. For instance:
using System;
using System.Windows.Forms;
class Test
{
static void Main()
{
NumericUpDown nud = new NumericUpDown();
nud.ValueChanged += new EventHandler (SayHello);
nud.Value = 20m;
}
static void SayHello (object sender, EventArgs e)
{
Console.WriteLine ("Hello");
}
}
displays "Hello" as expected.
Could you produce a similar short but complete program which
demonstrates the problem?
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
< di ****** **@discussion.microsoft.com>写道:
<di********@discussion.microsoft.com> wrote:
我在PANEL中有控件,它的Panel.Enabled = false,然后在处于false状态时我更新了NumericUpDown.Value属性及其
不开火。是否仅在启用容器中时才会触发?
I have the control in a PANEL and its got Panel.Enabled = false, then while
its in the false state I update the NumericUpDown.Value property and its
not firing. Does it only fire when its in an Enabled container?
如果你查看我发布的示例,它根本就不在容器中。
-
Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet
如果回复群组,请不要邮寄我也是
If you look at the example I posted, it''s not in a container at all.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
这篇关于设置NumericUpDown.Value属性时不会触发ValueChanged事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!