问题是:我想在点击按钮下面编写代码来调用另一个类中的方法
private void guocheng1_Click(object sender, EventArgs e)
{
MyCommands myMyCommands = new MyCommands();
MyCommands.Myds = new Myds() ;
}
public void Myds() // This method can have any name
{
// Put your command code here
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
ed.WriteMessage("\r\nThis is an Initialization Startup text.");
}
我不知道出了什么问题。
答案 0 :(得分:1)
private void guocheng1_Click(object sender, EventArgs e)
{
MyCommands myMyCommands = new MyCommands();
myMyCommands.Myds() ; //this, its not a static method. Also, this is how you call a method.
}
public void Myds() // This method can have any name
{
// Put your command code here
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
ed.WriteMessage("\r\nThis is an Initialization Startup text.");
}