0
I got a problem where I got two forms TelaInicio
and ExibirDados
and I’m trying to make sure that when the user double-click on some line in the Grid will open a form pulling the information relating to that line.
First I’m instantiating the form ExibirDados
in TelaInicio
public partial class TelaInicio : MetroFramework.Forms.MetroForm
{
internal ExibirDados exibirdados = null;
public TelaInicio(ExibirDados exibirdados)
{
InitializeComponent();
this.exibirdados = exibirdados;
}
And when giving Double Click on Grid I run this code:
private void dgvDados_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
{
if (dgvDados.SelectedRows.Count > 0)
{
this.exibirdados.txtcnpj.Text = dgvDados.SelectedRows[0].Cells[0].Value.ToString();
this.exibirdados.dtpcadastro.Text = dgvDados.CurrentRow.Cells[1].Value.ToString();
this.exibirdados.txtrazao.Text = dgvDados.CurrentRow.Cells[2].Value.ToString();
this.exibirdados.cmboperadora.Text = dgvDados.CurrentRow.Cells[3].Value.ToString();
this.exibirdados.txtlinhas.Text = dgvDados.CurrentRow.Cells[4].Value.ToString();
this.exibirdados.cmbClassificacao.Text = dgvDados.CurrentRow.Cells[5].Value.ToString();
this.exibirdados.dtpvigencia.Text = dgvDados.CurrentRow.Cells[6].Value.ToString();
this.exibirdados.txtcontrato.Text = dgvDados.CurrentRow.Cells[7].Value.ToString();
this.exibirdados.cmbFidelidade.Text = dgvDados.CurrentRow.Cells[8].Value.ToString();
this.exibirdados.txtvalorgasto.Text = dgvDados.CurrentRow.Cells[9].Value.ToString();
this.exibirdados.txtfixoempresa.Text = dgvDados.CurrentRow.Cells[10].Value.ToString();
this.exibirdados.txtgestor.Text = dgvDados.CurrentRow.Cells[11].Value.ToString();
this.exibirdados.txtcelular.Text = dgvDados.CurrentRow.Cells[12].Value.ToString();
this.exibirdados.txtfixogestor.Text = dgvDados.CurrentRow.Cells[13].Value.ToString();
this.exibirdados.txtemail.Text = dgvDados.CurrentRow.Cells[14].Value.ToString();
this.exibirdados.txtobs.Text = dgvDados.CurrentRow.Cells[15].Value.ToString();
}
ExibirDados form = new ExibirDados();
form.ShowDialog();
}
With this code he even opens the form but does not pull any information to the fields, the amount of fields is right and in my case the primary key is the CNPJ.