textbox value for another textbo using Tabcontrol and Tabpages

Asked

Viewed 109 times

1

I’m using in a form one TabControl, three-page.

In the TabPage1 have a TextBox (seller), I need to take the value of this Textbox to another TextBox who is in the TabPage3.

How can I do this between Tabcontrol pages when the form is unique?

Follows the Load() form:

private void frmComissaoPic_Load(object sender, EventArgs e)
{
    SqlCommand carrega = new SqlCommand(@"SELECT SA.A3_NREDUZ FROM SA3010 AS SA WHERE SA.A3_TIPO = 'E'", conexaoDADOADV(true));
    carrega.Connection = conex;
    carrega.CommandType = CommandType.Text;
    try
    {
        SqlDataReader dr = carrega.ExecuteReader();
        DataTable dt = new DataTable();
        dt.Load(dr);

        txt_vendedor.DisplayMember = "A3_NREDUZ";
        txt_vendedor.DataSource = dt;
    }
    catch (Exception)
    {
        MessageBox.Show("Não existem dados a retornar por favor verifique como o Administrador do sistema");
    }

    CloseButtonDisabler.DisableCloseButton(this.Handle.ToInt32());

    txt_vendatab3.Text = txt_vendedor.Text;            
    txt_nfe.Text      = "";
    txt_pedido.Text   = "";
    txt_item.Text     = "";
}
  • Need to "take the value" when? While typing? When clicking a button? When switching pages? By the way, the code posted is not useful for the question.

  • Good afternoon...so I need to take the amount when changing pages.

1 answer

2


Just use the event Selecting of TabControl

public void tabControl1_Selecting(object sender, TabControlCancelEventArgs e)
{
    txtDois.Text = txt_vendedor.Text;
    // Onde, txtDois é o TextBox que vai receber este dado
}

You can register the event using the form designer or in (or after) the method InitializeComponents()

public Form1()
{
    InitializeComponents();
    tabControl1.Selecting += tabControl1_Selecting;
}
  • Linq just one more question, I can within this command select and execute a query also when changing page without needing a button

  • @Juniorguerreiro Consegue

  • @Juniorguerreiro Managed to solve the publication problem?

  • Yes I solved yes..... Thank you..

Browser other questions tagged

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