L.Nash
L.Nash

Reputation: 1

how to call another method in C# in another class

  1. I want to use C# develop autocad and I build a new windows form project and add a button on it, I will put the parameter in the form.
  2. The question is: I want to write code below the click button to call the method in another class

    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.");   
    }
    

I don't know what's wrong.

Upvotes: 0

Views: 269

Answers (1)

Prajwal
Prajwal

Reputation: 4000

 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.");

}

Upvotes: 1

Related Questions