多窗口传值问题
有三个窗口:主窗口,查询窗口,查询集合窗口
主窗口点击查询弹出查询条件窗口,然后键入查询条件,按查询,查询窗口消失,
并将查询结果赋值给第三个窗口(查询集合窗口)
选取第三个查询记录中的记录来填充第一个窗口,同时关闭第三个窗口。
请问这类问题如何处理。
------解决方案--------------------e.g.
一些事件参数:
public class QueryConditionChangedEventArgs : EventArgs
{
 private string _someCondition;    
 public QueryConditionChangedEventArgs(string condition)
 {
    _someCondition = condition;
 }
 public string Condition
 {
   get{return _someCondition;}
 }
}
public class QueryCollectionSelectedEventArgs : EventArgs
{
 private string _seletedCondition;  
 public QueryCollectionSelectedEventArgs(string selected)
 {
    _selectedCondition = selected;
 }
 public string SelectedCondition
 {
   get{return _selectedCondition;}
 }
}
一些事件委托:
public delegate void QueryConditionChangedEventHandler(object sender, QueryConditionChangedEventArgs e);
public delegate void QueryCollectionSelectedEventHandler(object sender, QueryCollectionSelectedEventArgs e);
然后, QueryForm Closing中:
public event QueryConditionChangedEventHandler OnQueryConditionChanged;
private string _yourCondition;
private void QueryForm_FormClosing(object sender, EventArgs e)
{
 if(OnQueryCondtionChanged != null)
 {
   QueryConditionChangedEventArgs qce = new QueryConditionChangedEventArgs(_yourCondition);
   OnQueryConditionChanged(this, qce);
 }
}
MainForm中:
private void MainForm_Button1_Click(object sender, EventArgs e)
{
 QueryForm qf = new QueryForm();
 qf.OnQueryConditionChanged += new QueryConditionChangedEventHandler(foo);
 qf.ShowDialog(this);
}
private void foo(object sender, QueryConditionChangedEventArgs e)
{
  //feel free to handle the query condition by using e.Condition
}
其余类推