Sending a value from an interface to a previous interface

AMER SAID 396 Reputation points
2021-09-09T07:16:07.093+00:00

I have three simple interfaces Windows form. I want to send a value from the third interface it appears in the second interface .Where the second interface remains open, which is the main, and the third sub-interface is closed . The windows are opened in order from 1 to 3. Where I want the following: that the label appears on the second interface and a value is added to it.

I tried the following code and nothing works؟؟.

MAIN FORM2 = new MAIN();

           FORM2.LAB_A.Visible = true;
           FORM2.LAB_A.Text = DATATABLA.Rows.Count.ToString();
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
8,245 questions
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 95,156 Reputation points
    2021-09-09T07:58:36.677+00:00

    Try replacing the first line:

    MAIN form2 = (MAIN)Application.OpenForms["MAIN"];

    It assumes that there is a single form called "MAIN".

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful