Hello, I'm here with one more situation requesting help because I have not yet found it in the searches. I have a form that I put a Gridview in the form has button to open another form of query and when I click on an item from the list it adds in the form that is already open with the empty grid still follows code that I am trying to use: This is the initial form where the
public partial class frmPedidos : Form
{
public frmPedidos()
{
InitializeComponent();
}
ConexaoClienteDataContext cc = new ConexaoClienteDataContext();
private void btnProcSabor_Click(object sender, EventArgs e)
{
frmSlaveConsultaProduto _frmPRoduto = new frmSlaveConsultaProduto();
if (_frmPRoduto.ShowDialog() != DialogResult.OK)
return;
dgvItemPedido.CurrentRow.Cells[1].Value = _frmPRoduto.Codigo;
dgvItemPedido.CurrentRow.Cells[3].Value = _frmPRoduto.Valor;
}
}
This would be a query form and will allow you to click and send to the other grid of the main form
public partial class frmSlaveConsultaProduto : Form
{
public int Codigo { get; set; }
public string Nome { get; set; }
public double Valor { get; set; }
public int quantidade { get; set; }
public frmSlaveConsultaProduto()
{
InitializeComponent();
}
ConexaoClienteDataContext cc = new ConexaoClienteDataContext();
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
Codigo=Convert.ToInt32( dgvPesquisaProd.CurrentRow.Cells[0].Value.ToString());
Valor = Convert.ToDouble(dgvPesquisaProd.CurrentRow.Cells[2].Value.ToString());
this.DialogResult = DialogResult.OK;
}
The way it is it returns an error:
Additional information: Object reference not set to an instance of an object.
Thanks in advance for the help.