如何将Textbox值转换为另一种形式

如何将Textbox值转换为另一种形式

本文介绍了如何将Textbox值转换为另一种形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Ellooo People,

我有一个学校项目,我必须在Visual Studie 2013专业制作,我不知道现在该做什么...

我的项目/问题:

我需要制作一个表格,我可以登录和

然后进入主菜单,在那里可以找到文本(顶部的行)

我已经尝试了一切,但是程序说在目录中找不到名字

我已经到了点击登录的地方我去了主页菜单(另一种形式)



欲了解更多信息,请问我



greets



Mike

Ellooo People,
I have a school project that i have to make in Visual Studie 2013 Proffesional and i dont know what to do now...
My project/Problem:
I need to make a form where i can log in and
then get to a main menu where the text ( the line in the top ) can be found
I have tried everything but the program says that the name cannot be found in the directory
I'm already to the point where when i click login i go to the main menu (Another form)

For more information please ask me

greets

Mike

推荐答案

frmLogin log = new frmLogin();
if (log.ShowDialog() != DialogResult.OK)
   {
   Close();
   }

然后在登录表单中执行所有验证,然后单击确定或取消退出,具体取决于登录是否有效 - 如果不然,则上面的代码关闭应用程序。



所有你要做的就是在登录表单中添加一个属性,该表单返回登录用户名,并在主公司代码中访问它:

You then do all the validation in the login form and exit with OK or Cancel depending on if the logon works or not - if it doesn't, then the code above closes the application.

All you then have to do is add a property to the login form which returns the login user name, and access it in the main firm code:

Text = "User : " + log.UserName;


Public Class MyClass
{
public string myValue{get;set;}

}





登录表格:



Log in form:

If (textBox1.text==password and textBox2.Text==UserAccount)
{
  var cls=new myClass;//instantiate the class
  cls.myValue=textBox2.Text;//pass the value
  MainForm.ShowDialog();
}





然后是主表格



then in Main form

var cls=new myClass;
textBox3.Text=cls.myValue;


class Person
{
    public string UserName { get; set; }
    public string Password { get; set; }

    private Person()
    {
        Validate();
    }
    public Person()
    {

    }

    private void Validate()
    {
        //Here you must connect to some dataSource such as SQL server for correction of entry data
    }
}





3 - 现在你必须设计你的用户界面(表格)。

4-我想你创建一个表格两个TextBoxes和两个Button。在LogButton_Click中:



3-now you must design your UI(form).
4- I suppose you create a form that has two TextBoxes and two Button. In LogButton_Click:

public Form1()
{
    InitializeComponent();
}

private void LogInButton_Click(object sender, EventArgs e)
{
    Person person = new Person();
    person.UserName = UsernameTextBox.Text;
    person.Password = PasswordTextBox.Text;
}


这篇关于如何将Textbox值转换为另一种形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 05:08