我创建了一个表格。例如,一些表单事件方法如下所示:
private void BtnClose_Click(object sender, EventArgs e)
{
this.Close();
}
private void BtnRun_Click(object sender, EventArgs e)
{
this.Run();
}
private void BtnReset_Click(object sender, EventArgs e)
{
using (SqlConnection conn = new SqlConnection(Program.ConnStr))
{
using (SqlCommand cmd = conn.CreateCommand())
{
conn.Open();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "rt_sp_testAOFreset";
result = cmd.ExecuteNonQuery();
}
}
}
看起来简单明了,但我实际上是将表单继承到另一个类中。
public class Simulate : TableForm
所以,当我实例化Simulate类时......
Simulate sim = new Simulate();
Application.Run(sim);
Simulate当按钮来自类时,如何运行来自类的方法TableForm?例如,表单有一个“运行”按钮,其中事件方法包含在TableForm类中,但运行方法实际上在Simulate类中。
方法可以移动到Simulate类吗?还是可以Simulate由作为基类的类调用TableForm该类?