| |

VerySource

 Forgot password?
 Register
Search
View: 795|Reply: 8

Solve: under winform,

[Copy link]

2

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-3-15 19:00:01
| Show all posts |Read mode
The control association problem between main form1 and child form2: Now the content of textbox1 in form2 needs to be assigned to textbox2 in form1. How does it work? Please give me a method
Reply

Use magic Report

0

Threads

52

Posts

34.00

Credits

Newbie

Rank: 1

Credits
34.00

 China

Post time: 2020-6-14 18:45:01
| Show all posts
Directly access the value of the intermediate variable in the intermediate variable of the public attribute
Reply

Use magic Report

0

Threads

52

Posts

34.00

Credits

Newbie

Rank: 1

Credits
34.00

 China

Post time: 2020-6-14 20:45:02
| Show all posts
sorry typo

Define an intermediate variable for public attributes...
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-6-15 07:45:01
| Show all posts
ls can,
If there are many parameters passed, use delegate
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-6-15 11:45:02
| Show all posts
If it is a dialog box, you can enter the middle variable
public string textbox1text
{
get
{
return textbox1.text
}
}
Reply

Use magic Report

0

Threads

52

Posts

34.00

Credits

Newbie

Rank: 1

Credits
34.00

 China

Post time: 2020-6-15 13:00:02
| Show all posts
If there are multiple, you can also define a data structure or class
Used to pass parameters
Reply

Use magic Report

2

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-6-18 06:30:01
| Show all posts
Is it defined in form1 or intermediate variable in form2?
Reply

Use magic Report

0

Threads

52

Posts

34.00

Credits

Newbie

Rank: 1

Credits
34.00

 China

Post time: 2020-6-18 10:45:01
| Show all posts
Ok
Reply

Use magic Report

0

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-6-18 21:00:01
| Show all posts
There are multiple methods for assigning controls between forms:
1. Use event delegation
2. Change the private declaration of the form control to public,
   Take one form as the parent form and the other as the child form, you can set the control value of the child form in the parent form
3. If it is accessed when it is loaded, it is directly passed as a parameter in the form constructor.
4. Write a class, define static properties or methods (set and get),
   Can assign values ​​in one form, get values ​​in another form
...
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list