Picking up content from a textbox from another frame

Asked

Viewed 63 times

0

Guys I need a little help, I have an app that I need to pick up the contents of a textbox in another form to put in a homebody.

        private void PDVForm_Load(object sender, EventArgs e)
    {
        var Operador = "";//qual o codigo que vai aqui?;
        MessageBox.Show("Olá " + Operador,"Bem-Vindo",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Information);
    }
  • here is an example of a login form: https://answall.com/a/205488/69359

1 answer

1


I would receive the name of the operator in the Pdvform constructor

On the other form it would look like this

private void BtnLogin_Click(object sender, EventArgs e)
{
    PDVForm form = new PDVForm(txtOperador.Text);
    form.Show();
}

On the Pdvform

public partial class PDVForm : Form
    {
        private string operador;

        public PDVForm(string Operador)
        {
            operador = Operador;
            InitializeComponent();
        }

        private void PDVForm_Load(object sender, EventArgs e)
        {            
            MessageBox.Show("Olá " + operador, "Bem-Vindo",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Information);
        }
    }

EDIT: I’m obviously not taking the validation rules into account.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.