我尝试继承方法button1_click,我收到了上面的消息,如何修复?
namespace visualinheritance
{
public partial class usercontrolcommon : UserControl
{
public usercontrolcommon()
{
InitializeComponent();
}
public void button1_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show("usercontrolcommon");
}
}
}
namespace visualinheritance
{
public partial class usercontrol1 : usercontrolcommon
{
public usercontrol1()
{
InitializeComponent();
this.button1.Click += new MouseEventHandler(button1_Click);
}
}
}
答案 0 :(得分:2)
按钮单击事件不是鼠标事件。只需将处理程序更改为button1.Click += button1_Click;
即可使用