How do I call a public methods in my 'public class' (as c# module) in c#?

115 Views Asked by At

There are only (3) things I need to know in here. Firstly, there is only (1) button (close_button) in this form. Here's my frm_main.cs code:

public partial class frm_main : Form
{
    public_class pc = new public_class();
    public frm_main()
    {
        InitializeComponent();
        this.Load += new System.EventHandler(frm_main_Load);
    }
    private void close_button_Click(object sender, EventArgs e)
    {
        this.Close();
    }
    private void frm_main_Load(object sender, EventArgs e)
    {
        pc.screen_adjust(close_button);
    }
}

And here's my public_class.cs code:

public partial class public_class
{
    public int cl_b;
    public void screen_adjust(Button b)
    {
        cl_b = frm_main.ActiveForm.Width;
        frm_main.ActiveForm.Width = Screen.PrimaryScreen.Bounds.Width;
        frm_main.ActiveForm.Height = Screen.PrimaryScreen.Bounds.Height;
        b.Left += frm_main.ActiveForm.Width - cl_b;
    }
}

The aim of this borderless program is to auto-stretch the form to the whole screen. Now, what I'd like to learn is:

  1. Did I do a correct "VB.net module" in C# properly?
  2. How do I call the methods in public_class.cs without using the 'public_class pc = new public_class();' and 'pc.screen_adjust(close_button);'?
  3. In the public_class.cs, for example, if I want to change the close_button's text, how should I do it? I can't do frm_main.close_button afterall...

Thanks!

0

There are 0 best solutions below