2015-02-06 62 views
-3

我希望在登录表单中输入的用户名(txtusername)以其他形式(比如form2)可用,以便我可以在cmd.parameters中使用它们.addwithvalue( “@ last_updated_user”,txtusername.text);以及form2中的其他参数(文本框值)。 最新的成本更新如何使用在其他形式的form1的文本框中输入的值

+0

看到这个答案http://stackoverflow.com/questions/20186722/pass-a-value-from-one-form-to-another – 2015-02-06 08:56:01

+0

你尝试过什么/研究?如果你将你的“答案”复制到谷歌,那么你需要的答案会有多个重复 – Sayse 2015-02-06 08:56:28

回答

-1
You can use static vars, which would be the easiest solution but if you have multiple instances and you change the static varibale in just one the change will also effect all other instances. , personally I think constructors 
so 

create a constuctor for the second form which accepts 2 arguments 

i.e 

FormWhatevz form2= new FormWhatevz (textBox1.Text,textBox2.Text); 
" in Form1 Code or anywhere really.." 

form2.Show(); 

Constructor: 

public FormWhatevz(string loginUserName,string Password) 
    { 
     InitializeComponent(); 
     textbox1value.Text = loginUserName; 
     textbox1value.Text=Password; 

    } 

Hope this helps , this source shows multiple ways of parsing data 
between forms , source : http://www.codeproject.com/Articles/14122/Passing-Data-Between-Forms  
相关问题