听另一个userController [英] listening to another userController

查看:62
本文介绍了听另一个userController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我在我的项目中使用了两个用户控制器,每个都有一个模型。

现在我必须在userController_2上更改值,如果值改变了userController_1中的numUpDownBx ...



怎么办?



thanx

解决方案



很好,你可以在课堂上创建一个get和set属性,

  class  numericUpdown { public   static   int  NumericUpDownValue { get ;  set ;在数字更新事件更改事件中,userController中的


您可以像这样设置属性值

 numericUpdown.numericUpdownValue = numUpDownBx。 value ; 





现在在userController_2中创建一个从正确性中获取值的函数

认为我在userController_2中有一个textbox1并且我想从numericUpDown获取值然后我可以像这样写

  void  getValuefromUserControl1()
{
textBox1.text = numericUpdown.numericUpdownValue.Tostring();
}



在一个帖子中调用

 getValuefromUserControl1()



喜欢这个



线程th = 线程( getValuefromUserControl1); 
th.start();





有关线程的详细信息,请点击此链接

< a href =http://www.albahari.com/threading/> http://www.albahari.com/threading/ [ ^ ]



C#中的线程化攻击 [ ^ ]





http://msdn.microsoft.com/en-us/library/aa645740%28v=vs.71%29.aspx [ ^ ]





希望它可以帮到你


Hi All,
I am using two user controllers in my project, each one with Models.
Now I have to change values on userController_2 if a value changes in a numUpDownBx in userController_1...

how is this to do?

thanx

解决方案

Hi,
Fine you can take a class create a get and set property in it ,

class numericUpdown { public static int NumericUpDownValue{ get; set; }}



in userController in numeric updown change event you can set the property value like this

numericUpdown.numericUpdownValue =numUpDownBx.value;



and now in userController_2 create a function which gets value from properity
Think that i am having a textbox1 in userController_2 and i want to get value from numericUpDown then i can write like this

void getValuefromUserControl1()
{
textBox1.text= numericUpdown.numericUpdownValue.Tostring(); 
}


call

getValuefromUserControl1()

in a thread
like this

Thread th=new Thread(getValuefromUserControl1);
th.start();



For more information about Threading follow this link
http://www.albahari.com/threading/[^]

Threading in C#[^]


http://msdn.microsoft.com/en-us/library/aa645740%28v=vs.71%29.aspx[^]


Hope it may help you


这篇关于听另一个userController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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