窗口之间通过委托传值监听的问题
独孤侠客 2012-07-09 09:57:52 我本意是通过点击窗口NetChart4中pictureBox的不同位置让另一个窗口DeviceList中的ListView中的不同的对应的选项被选中,也对委托不熟,请高手赐教,不甚感激!
首先我在窗口NetChart4中创建了一个委托:
public partial class NetChart4 : UserControl
{
public NetChart4()
{
InitializeComponent();
}
public delegate void ShowSelectedPoint(object sender);
public event ShowSelectedPoint SelectedPoint;
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
if (SelectedPoint != null)
{
SelectedPoint("卫星接收机");
}
}
}
然后在窗体DeviceList中监听NetChart4中的事件
public partial class DeviceList : UserControl
{
NetChart4 netChart4;
public DeviceList()
{
InitializeComponent();
netChart4 = new NetChart4();
//监听事件
netChart4.SelectedPoint+=new NetChart4.ShowSelectedPoint(selecedjpg);
}
public void selecedjpg(string str)
{
for (int i = 0; i < this.listView1.Items.Count; i++)
this.listView1.Items[i].Selected = false;
}
}
结果报错:
Error 1 No overload for 'selecedjpg' matches delegate 'Demo.MyControler.NetChart4.ShowSelectedPoint'
请高手解答啊,在线等,谢谢。