
具体代码就不写了,直接说思路,重置输入之前的内容,应该是有一个或者多个EditText,如果这个/这些EditText中有默认的值,你可以在点击的监听事件中将EditText中的值设置为默认值,如果没有默认值,则可以直接将这些EditText中的值设置为null.
好问题!当时我也是在网上找了很久,然后才写出来的。我就讲下大体说下吧。
1.自定义控件事件最主要的是参数的传递,而参数是写在事件里的,所以需要定义一个事件
public class EventMoveArgs : EventArgs
{
public EventMoveArgs(xx,xx)
{
.....
}
}//主要用来传递参数,用构造函数
2.声明委托和事件
public delegate void PieceMoveEventHandler(object sender, EventMoveArgs e)//参数名与事件类名
public event PieceMoveEventHandler PieceMoveEvent_Click//注意名称一致
3.虚方法
protected virtual void OnPieceMove(EventMoveArgs e)
{
if (this.PieceMoveEvent_Click != null)
PieceMoveEvent_Click(this, e)
}
4.自定义控件内部的基本控件的事件
private void uPB_Click(object sender, EventArgs e)//比如Button1_Click
{
OnPieceMove(new EventMoveArgs(0, -1))
}
几本上足够了,你就照着这个该下函数名改就可以了。
最后添加好后在自定义控件事件列表中会多出个OnPieceMove,即你需要的自定义控件事件。
参考的网址可以看下。
记得采纳o(∩_∩)o ~
你可以加入下面的代码:private void button1_Click(object sender, EventArgs e)
{
this.FormClosing += new FormClosingEventHandler(Form1_FormClosing)
}
void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (MessageBox.Show("你确定关闭窗口吗?","Application",MessageBoxButtons.YesNo,MessageBoxIcon.Information)==DialogResult.No)
{
e.Cancel = true
}
}
希望对您有帮助。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)