将组件属性联系在一起 [英] tying together component properties

查看:79
本文介绍了将组件属性联系在一起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.

可以说我有一个带有两个文本框和一个复选框的胜利形式.

我可以这样说:

Hi.

Lets say I have a win form with two textboxes and one checkbox.

I can say something like:

checkbox1.checked = textbox1.text.length==0 && textbox1.text.length!=0



但是,只要textbox1或textbox2发生更改,是否可以自动重新评估该值-无需对textbox1和textbox2进行显式事件处理?

种类,当您拥有Excel文档并定义公式时,以及更改输入单元格时,公式将重新计算

那么是否有一个框架可以通过这种方式将组件属性联系起来?



But is it possible to automatically reevaluate this whenever textbox1 or textbox2 changes - without explicit event handling on textbox1 and textbox2?

Kind of, when you have an Excel document, and you define formula, and when you change input cell, the formula gets recalculated

So is there a framework to tie component properties this way?

推荐答案

也许使用lambda表达式将它们联系在一起.您仍将使用该事件,但没有显式方法.

Maybe use a lambda expression to tie them together. You still would use the event but without an explicit method.

textbox1.LostFocus += (s,e) => { checkbox1.checked = textbox1.text.length==0 && textbox1.text.length!=0;};



祝你好运!



Good luck!


这篇关于将组件属性联系在一起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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