我最近更改了我的项目以包含一个更好的集成接口。我真的被困在如何从我的接口继承的类中访问一个表单上的方法(用于更新表单控件)。下面是一些代码片段,应该有助于清晰。如何在C#中不创建对象的情况下在其他类中使用非静态方法
//this is the double click event from where i have to call SelectDeal method
private void TodayEventsGridView_DoubleClick(object sender, EventArgs e)
{
DealModule _dealModule = new DealModule();
// i dont want to create an obect of class DealModule()
try
{
this.Cursor = Cursors.WaitCursor;
_dealModule.SelectDeal(DealKey);
}
catch (Exception ex)
{
MessageBox.Show("Warning: " + this.ToString() + " " + System.Reflection.MethodInfo.GetCurrentMethod().Name + "\n" + ex.Message, ex.GetType().ToString());
}
finally
{
this.Cursor = Cursors.Default;
}
}
你不知道。不可能。 – 2014-10-08 14:37:47
你能否详细说明为什么你不想创建DealModule类?也许我们可以建议一个更好的解决方案,如果我们更了解你的约束。 – JMarsch 2014-10-08 14:38:55