I've created a form. As an example, some of the form event methods look like this:
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();
}
}
}
Seems simple and straightforward, but I'm actually inheriting the form into another class.
public class Simulate : TableForm
So, when I instantiate the Simulate
class...
Simulate sim = new Simulate();
Application.Run(sim);
How do I run a method that is from the Simulate
class, when the buttons are from the TableForm
class? E.g. The form has a "Run" button where the event method is contained in the TableForm
class, but the run method is actually in the Simulate
class.
Can the methods be moved to the Simulate
class? Or can the Simulate
class be called by the TableForm
class being the base class?