Hello, I'm trying to do something that looks simple but I'm not getting it, I want to click a button to add the data from a grid go to another form that is already open. The problem is that I am only able to load a new form. This is not what I want. It follows the code for help:
Add Form1 button event
private void btnAdicionar_Click(object sender, EventArgs e)
{
frmPedidos frmped = new frmPedidos(CODIGO, NOME, TELEFONE, ENDERECO);
CODIGO = int.Parse(dgvConsultaCliente.CurrentRow.Cells[0].Value.ToString());
NOME = dgvConsultaCliente.CurrentRow.Cells[1].Value.ToString();
TELEFONE = dgvConsultaCliente.CurrentRow.Cells[2].Value.ToString();
ENDERECO = dgvConsultaCliente.CurrentRow.Cells[3].Value.ToString();
frmped.Show();// aqui que ele carrega outro form tanto faz se usar ShowDialog ou Show mesmo
}
Form 2
public frmPedidos(int codigo, string nome, string telefone, string endereco)
{
InitializeComponent();
txtCodCliente.Text = codigo.ToString();
txtNomeCliente.Text = nome;
txtTelefoneCliente.Text = telefone;
txtEndCliente.Text = endereco;
}
I want to fill in form2 already open and not in a new form because I will put more other tables that will do the same process if I do this in all I will lose the information.
Thanks in advance.