如何将登录表单控件调用到另一个表单 [英] How to call Login form control to another form

查看:81
本文介绍了如何将登录表单控件调用到另一个表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Windows应用程序项目中,我有登录表格

在登录表单中,我具有诸如username = txtusername之类的控件;密码= txtpassword

这两个控件,我将通过,我将在此处获取用户ID,此用户ID,我想保存其他花药表格,该怎么办?

Hi I am doing windows application project in this i have login form

in login form i have controls like username = txtusername ; password = txtpassword

this two controls i will pass i will get user id here this user id i want to save some anther form how to do?

推荐答案

如果将值传递给另一个表格表示首先创建全局变量并存储该值,然后将值传递给另一种形式,下面的示例代码尝试使用此方法
If you pass values to another Form means first created global variables and stored that values and then pass values to another form , below Sample code try this one
 public global{
public static String gblLoginID ;
public static String  gblPassword ;
}

public class Form1{
global .gblLoginID=textbox1.text;
}
public class Form2{
textbox2.text=global .gblLoginID;
}



您也可以使用Constructor

Hi ,
You can also use Constructor

//Form1
private void button1_Click(object sender, EventArgs e)
{
    Form2 frm = new Form2(txtUser.Text , txtPass.Text);
    frm.Show();
}
//Form2
  string username1, password1;
        public Form2(string username  , string password)
        {
            InitializeComponent();
            username1 = username ;
            password1 = password ;
        }
        private void Form2_Load(object sender, EventArgs e)
        {
            MessageBox.Show(username1+"  "+password1);
        }


最好的问候
M.Mitwalli


Best Regards
M.Mitwalli


我希望这会对您有所帮助
^ ]
I hope this will help you
http://stackoverflow.com/questions/1425719/retrieve-values-from-one-form-to-another-in-windows-application-using-c-sharp[^]


这篇关于如何将登录表单控件调用到另一个表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆