'Calling method from another class - Winforms C#

I am trying something like below and I am getting red lines under any formDesign commands such as messageBox, dataGridView etc.

I want to put the body of the methods in a seperate .cs page for neatness and call them from mainForm.cs

Is this the wrong way to call methods

mainForm.cs

namespace App{
      public partial class mainForm : Form{
             private void saveCSVbutton_Click(object sender, EventArgs e){
                className.method();
             }
      }
}
class.cs

namespace App{
      class className{
              private void method(){MessageBox.Show("No Record To Export", "Info");}
      }
}


Solution 1:[1]

If you want to separate different layers of an app, I suggest you use a design pattern like MVVM. This way you would have classes that does the functionality of the app and other classes work with database and so on.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mohamad mohamadi