关于C#事件问题The modifier 'private' is not valid for this item
public Form1(){
InitializeComponent();
winPlayer.PlayStateChange+=new WMPLib._WMPOCXEvents_PlayStateChangeEventHandler(winPlayer_PlayStateChange);
}
private void winPlayer.PlayStateChange(object sender, WMPLib._WMPOCXEvents_PlayStateChangeEventHandler e)
{
if (winPlayer.playState == WMPLib.WMPPlayState.wmppsMediaEnded)
timer1.Enabled = true; ;
}
结果调试的时候出现The modifier 'private' is not valid for this item
谁能告诉这是什么原因啊? --------------------编程问答-------------------- 有其他静态函数或者静态属性调用了winPlayer.PlayStateChange?
是的话winPlayer.PlayStateChange一定要是静态的啊
先改成静态(static)的看看吧... --------------------编程问答-------------------- private void winPlayer.PlayStateChange(object sender, WMPLib._WMPOCXEvents_PlayStateChangeEventHandler e) 好像这个是在调用系统的API吧?
定义调用系统API时,函数要静态的,即函数要加static --------------------编程问答-------------------- 加static,结果 “static"is not valid for this item....... --------------------编程问答-------------------- 把 private 去掉,如果不行,就改成 public 。
补充:.NET技术 , C#