English 中文(简体)
A. 如何在二次控制中参考一用户中的物体
原标题:How to reference objects in one UserControl from code in a second control
  • 时间:2009-09-07 10:37:50
  •  标签:

In one UserControl I have option buttons that are supposed to change the visibility of rectangles in another user control and I can t find out how to do this. Can anyone give me some code example for this?

问题回答

用户控制应当引起一项活动,即第二次控制会被用于改变知名度:

//FirstControl
public event EventHandler SelectionChanged;
private void OnOptionButtonSelectionChange(....)
{
  if (SelectionChanged != null)
    SelectionChanged(this, EventArgs.Empty);
}

//SecondControl
public void Setup()
{
  firstControlInstance.SelectionChanged += new EventHandler(manage_SelectionChanged);
}

private void manage_SelectionChanged(Object sender, EventArgs e)
{

}

或者,如果控制被分解,你可以像以下那样使用调解人:





相关问题
热门标签