如何将登录表单控件调用到另一个表单

编程入门 行业动态 更新时间:2024-10-10 19:21:34
本文介绍了如何将登录表单控件调用到另一个表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在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

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

更多推荐

如何将登录表单控件调用到另一个表单

本文发布于:2023-11-02 10:01:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1552085.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表单   控件   如何将

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!