how to update a VS2022 form from another namesapace

14 Views Asked by At

i am a relatively inexperienced/casual VS2022 programmer. i know enough to get into problems. i have a windows form application that is part of a calibration system. The main form that starts has status windows and characteristics that are updated. Then once everything is calculated it downloads to the equipment. There is a button on the form to start the calibration process, this calls code in a separate namespace. During the process i have some code in a separate namespace , nearly 2000 lines of code and calculations. hence it is not in the main form code. i want to be able to update the main calling form with some of the calculations as the process continues. the original calling form is M_Cal_form() so in the separate code i have

public class Serial_Interface
{
     public static string find_M()
     {
        var mf = new M_Calibration.M_Cal_form();
        .
        .
        .
        mf.txtStatus.Text = "Connecting2....." + port_name;
        mf.Refresh();
        .
        .
        .
        .
     }
}

txtStatus is a text box on the main form. There are more than 20 text boxes and other lists but i think 1 example makes it easier. i tried mf.Activate(); before the update nothing i did try mf.Show(); this created a new instance of the main form and updated the various boxes but i had 2 forms showing, not what i wanted. This did look weird! It seems to me that i am not targeting the original form in my updates.

Any advice appreciated.

See above on what i tried.

0

There are 0 best solutions below