I have a solution in Visual Studio 2013 which contains two Forms. I want when a button pressing in Form2, the variable flag_fb
is updated and I use its value in Form1. Is there any way to do this? Thanks.
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
Method1 : using parameterized constructor to pass the variables between forms
create a parameterized constructor for
Form1
and call the Form1 parameterized constructor from Form2 :call the
Form1
parameterized constructor fromForm2
as below:Method2 : create your variable
flag_fb
aspublic static
variable inForm2
so that it willbe accessible fromForm1
aswell.To access the
flag_fb variable
fromForm1
just use className as below:Something like this should also work.
You should make sure
flag_fb
is public member variable ofForm2
, and also make sure it is set to desired value when user clicks OK for instance.