public void Command8_Click(System.Object eventSender, System.EventArgs eventArgs)  {
DialogEnterDish.Default.ShowDialog();
}也就是说,主窗体的实例指针this,如何通过eventSender参数或eventArgs参数传递给对象Command8,让对象Command8也知道它所在的窗体的现在的情形。

解决方案 »

  1.   

    1、不需要传递,在此方法中直接可以使用该按钮所属窗体的this指针
      

  2.   

    2、sender即button实例,若此button的父级为窗体,也可以使用((Button)sender).Parent的方式获取到窗体的引用
     示例:        private void button1_Click(object sender, EventArgs e)
            {
                MessageBox.Show(this.Text);
                object p = ((Button)sender).Parent;
                MessageBox.Show(this.Equals(p).ToString()); //True表示this和p是引用同一个实例的        
             }