事件的问题?
//第一步:设置一个指代
public delegate void ProgressCompleteHandle(object sender,EventArgs e);
//第二步:
private event ProgressChangedEventHandler ProComplete;
//第三步:
private void Complete()
{
MessageBox.Show( "OK ");
}
private void button1_Click(object sender, EventArgs e)
{
this.progressBar1.Minimum = 0;
this.progressBar1.Maximum = 100;
for(int i=this.progressBar1.Minimum;i <=this.progressBar1.Maximum;i++)
{
this.progressBar1.Value = i;
}
this.progressBar1.ProComplete += new ProgressCompleteHandle(this.Complete);
想定义一个事件,当进度条完成的时候执行,帮我看看怎么不行。
还有我怎么能把设置成跟button 的click事件一样,能够很方便的是使用
------解决方案--------------------这句写在构造函数中..
this.progressBar1.ProComplete += new ProgressCompleteHandle(this.Complete);
试试..
------解决方案--------------------//第一步:设置一个指代
public delegate void ProgressCompleteHandle(object sender,EventArgs e);
//第二步:
private event ProgressChangedEventHandler ProComplete;
//第三步:
private void Complete()
{
if (ProComplete!=null)
{
ProComplete(this, new EventArgs());
}
}
......
------解决方案--------------------原来类型不一样啊....
这样:
//第一步:设置一个指代
public delegate void ProgressCompleteHandle(object sender,EventArgs e);
//第二步:
private event ProgressCompleteHandle ProComplete;
//第三步:
private void Complete()
{
if (ProComplete!=null)
{
ProComplete(this, new EventArgs());
}
}
......
------解决方案--------------------try..
//第一步:设置一个指代
public delegate void ProgressCompleteHandle(object sender, EventArgs e);
//第二步:
private event ProgressChangedEventHandler ProComplete;
//构造函数中
public Form1()
{
InitializeComponent();
this.ProComplete += new ProgressChangedEventHandler(Complete);
//第三步:
private void Complete(object sender, EventArgs e)