首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

c#如何满足多个事件

2012-10-08 
c#怎么满足多个事件如题,本人刚学c#,我想在2件事件同时满足或者说是触发时,才执行某条语句,例如[codeC#][

c#怎么满足多个事件
如题,本人刚学c#,我想在2件事件同时满足或者说是触发时,才执行某条语句,
例如
[code=C#][/code] private void UserName_TextChanged(object sender, TextChangedEventArgs e)
  {
   
  }

  private void Password_PasswordChanged(object sender, RoutedEventArgs e)
{
 button1.IsEnabled = true;

}
同时满足上面2个事件,设置按钮为可用


[解决办法]
你看 给个bool 值 能满足要求不?
public partial class Form1 : Form
{
bool one = false, two = false;
public Form1()
{
InitializeComponent();
}

private void textBox1_TextChanged(object sender, EventArgs e)
{
//if() 这里可以给个条件如果满足了 才one = true;
one = true;
if ((one == true) && (two == true)) button1.Enabled = true;

}

private void textBox2_TextChanged(object sender, EventArgs e)
{
two = true;
if ((one == true) && (two == true)) button1.Enabled = true;
}
}
[解决办法]

探讨

你看 给个bool 值 能满足要求不?
public partial class Form1 : Form
{
bool one = false, two = false;
public Form1()
{
InitializeComponent();
}

……

热点排行