按钮单击事件的代码 [英] Code for Button Click Event

查看:161
本文介绍了按钮单击事件的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我想要运行的代码,这样如果结果为true,则会更改

当前按钮'''DialogResult"属性为DialogResult.OK。问题是,当我在.Click上运行此代码时,
当前按钮的事件然后

运行此代码,如果是.DialogResult属性是变化的,在再次按下按钮之前不会产生

影响。


我可以解决这个问题吗?

解决方案

" Sarah" < SA ******** @ powertechcanada.com> schrieb

我有我想要运行的代码,这样如果结果为真,它会改变当前按钮'''DialogResult"属性
DialogResult.OK。问题是,当我在当前按钮的.Click
事件上运行此代码然后运行此代码时,如果
.DialogResult属性是变化的,只有再次按下
按钮才会生效。

我会解决这个问题吗?




为什么不在第一次点击时执行代码?

-

Armin


< blockquote>


为什么不在第一次点击时执行代码?




我是执行按钮上的代码点击事件。当代码

的计算结果为true时,它会将当前按钮控件.DialogResult

属性更改为.DialogResult.OK。问题是,当我在这个按钮单击事件中更改此设置

时,更改不会立即发生 -

即因为按钮已被按下,所以更改

后按下它的属性没有达到预期的结果 - 即更改

" .DialogResult"属性是这个点击事件。 (.DialogResult.OK

属性更改仅适用于下次按下按钮_)。


任何帮助将不胜感激,以了解如何运行代码来更改

..DialogResult属性,以便更改会立即改变

按钮的行为。


谢谢。


" Sarah" < SA ******** @ powertechcanada.com> schrieb


为什么不在第一次点击时执行代码?


我正在按钮上执行代码click事件。当
代码评估为true时,它会更改当前按钮控件
" .DialogResult"属性为.DialogResult.OK。问题是,当我在这个按钮单击事件中更改此设置时,更改确实不会立即发生 - 即因为按钮已被按下,所以更改了它的属性按下它不具有所需的结果 - 即更改.DialogResult
属性是此单击事件。 (.DialogResult.OK属性更改
仅适用于下次按下按钮_)。

任何帮助将不胜感激,以了解如何运行代码来更改
.DialogResult属性,以便更改会立即改变按钮的行为。




每当我更改dialogresult属性时,它都会立即更改。

-

Armin


I have code that I want to run so that if the result is true, it changes the
current button''s ".DialogResult" property to "DialogResult.OK". Problem is,
when I run this code on the ".Click" event for the current button and then
run this code, if the ".DialogResult" property is change, it does not take
affect until the button is pressed again.

I do I workaround this?

解决方案

"Sarah" <sa********@powertechcanada.com> schrieb

I have code that I want to run so that if the result is true, it
changes the current button''s ".DialogResult" property to
"DialogResult.OK". Problem is, when I run this code on the ".Click"
event for the current button and then run this code, if the
".DialogResult" property is change, it does not take affect until the
button is pressed again.

I do I workaround this?



Why don''t you execute the code on the first click?
--
Armin



Why don''t you execute the code on the first click?



I am executing the code on the buttons "click" event. When the code
evaluates to true, it changes the current buttons control ".DialogResult"
property to ".DialogResult.OK". The problem is, when I change this setting
in this buttons click event, the change does not take place right away -
i.e. since the button was already pressed, changing the property of it after
it is pressed is not having the desired result -- which is to change the
".DialogResult" property was this click event. (The .DialogResult.OK
property change only works for the next time the button is pressed_).

Any help would be appreciated to find out how to run code to change the
..DialogResult property so that the change would change the behavior of the
button right away.

Thanks.


"Sarah" <sa********@powertechcanada.com> schrieb


Why don''t you execute the code on the first click?



I am executing the code on the buttons "click" event. When the
code evaluates to true, it changes the current buttons control
".DialogResult" property to ".DialogResult.OK". The problem is, when
I change this setting in this buttons click event, the change does
not take place right away - i.e. since the button was already
pressed, changing the property of it after it is pressed is not
having the desired result -- which is to change the ".DialogResult"
property was this click event. (The .DialogResult.OK property change
only works for the next time the button is pressed_).

Any help would be appreciated to find out how to run code to change
the .DialogResult property so that the change would change the
behavior of the button right away.



Whenever I change the dialogresult property it does change right away.
--
Armin


这篇关于按钮单击事件的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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