Update Form1 with Form2 in C

Updated on Car 2024-05-17
17 answers
  1. Anonymous users2024-02-10

    It's a mess of what you're saying、I know what you're mainly doing、Make an example for you。

    If it's multiple updates, let's say you want to update form1 grades through form2, and you need to update it multiple times.

    You first declare public form1 f=new form1() in the form2 form;

    Then you show form2form2 f2=new form2() in form1;

    Pass the object of form1 to form2

    You can then update the form1 score from form2.

    There is also an update.

    You can declare a global variable public string name=null in fom2;

    Passing the results at the same time as form1 shows form2.

    form2 f2=new form2();

    Grades";;

  2. Anonymous users2024-02-09

    Pass form1 as an object parameter to form2 and change the content of form1 directly in form2.

  3. Anonymous users2024-02-08

    1 The subwindow defines a delegate type that can be invoked when needed.

    2.This delegate is injected when the main window instantiates a child window, and a function is defined in the main window to modify the control.

  4. Anonymous users2024-02-07

    On the other hand, the syntax is wrong, it should be public static and the variable should be defined in form2.

    public partial class form2 : form.

    is defined as global, and then when show form2, the form name. This variable name can come out. Specifically, take a look at the form transfer value.

  5. Anonymous users2024-02-06

    Create a class, define the static public string variable name in the class, then pass the value of form1 to the variable, and use the value of form1 from the class in form2.

  6. Anonymous users2024-02-05

    Set the variable name to the attribute value of f1, and f2 can be read.

    c Presumably local variables are not supported.

  7. Anonymous users2024-02-04

    Let's take a look at this basic book on how member variables can be defined in functions.

  8. Anonymous users2024-02-03

    As long as you make sure that form1 has received the value, you can close the form2 form.

    In form2, when you click button2, write = before closing the form;

    Then, when form2 is called in form1.

    form2 frm2 = new form2();

    if ( ==

  9. Anonymous users2024-02-02

    First of all, you write this in form2 when you click button2 before closing the form.

    Then, when form2 is called in form1.

    form2 frm2 = new form2();

    if ( ==

  10. Anonymous users2024-02-01

    The landlord is talking about MDI, right? form1 is the parent form, form2 is the child form, and the movement range of the child form can only be moved within the size range of the parent form;

    true;Sets the current form as the parent form.

    subform test= new subform();

    this;;

  11. Anonymous users2024-01-31

    Set form1 as the parent window, form2 as the child window of form1, and show form2 will be in form1. Detail** can be used directly to create a parent-child form project with vs, vs has that project to build, and as soon as it is built, it is a parent-child form instance that can be used directly.

  12. Anonymous users2024-01-30

    To first set form1 as the parent form, this is changed to form2 by property form2=new form2();

    form1);

  13. Anonymous users2024-01-29

    The landlord can write like this.

    In the event that loads form2.

    In this way, form2 will only be opened after closing form1.

  14. Anonymous users2024-01-28

    It doesn't seem to work, but it needs to be defined in form2 as well!

  15. Anonymous users2024-01-27

    Compared with the public function mentioned by the two handsome guys above, it is recommended that you learn to use a delegate or an event (in fact, an event is a special case of a delegate, we click a button to trigger an event is actually a delegate. )

    Learning to invoke delegates or events is the only way to learn C. Very simple things are complicated by books. This is what will be commonly used for cross-thread calls in the future. If you want to improve, you must master it.

    The problem you're talking about is actually a cross-window call problem, and the method of using static variables is relatively primitive and awkward to refresh. The common practice is to use events or delegates to do this. Below** 15 lines to complete your needs, concise and concise.

    form1.

    Click a button to pop up form2.

    form2 f = new _form2();

    f._bbb+= new eventhandler(_aaa);

    Define the AAA above

    private void _aaa(object sender, eventargs e)

    form2.

    public event eventhandler _bbb;

    button in form2.

    if (_bbb!= null)

    Explain the above**.

    1. Define a function -aaa() in form1, which is responsible for adding and deleting data to combox.

    2. At the same time, add the ** that pops up form2 in form1.

    In this case, you want to add an event that calls the function aaa().

    3. Go to form2 to define a bbb event for the above 2 to call;

    4. In form2, after clicking the button, call aaa() of form1. Parameters can be null. This place may be difficult to understand, ponder carefully

  16. Anonymous users2024-01-26

    Define a public variable in form2, click it, hide form2, remember not to close.

    You can use this variable directly in form1.

  17. Anonymous users2024-01-25

    Build a structure in the program; It defines a static variable that can be used in both form1 and form2; Just assign a value directly;

    using system;

    using ;

    using ;

    using ;

    namespace form1form2

    static class program{///

    The main entry point to the application. ///

Related questions
24 answers2024-05-17

The easiest way to do this is to create a constructor with a string parameter in form2, and then generate a form2 form. >>>More

6 answers2024-05-17

vectorivec2;

int i=0,num=0; >>>More

20 answers2024-05-17

That's it, this belongs to the parameter transfer between forms, there are many ways! >>>More

29 answers2024-05-17

Check this out. <>

You can also knock ** yourself. >>>More

8 answers2024-05-17

You can use function pointers, such as:

voidfunction(int >>>More