2
Hello I’m here with another situation requesting help because there is not yet found in the surveys. I have a form that I put a Gridview, the form has button to open another query form and when I click on an item in the list it adds in the form that is already open with the empty grid still follows code I am trying to use: This is the initial form where it contains the button
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 the query form and will allow clicking and sending 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: Undefined object reference for an object instance.
Thanks for your help.
So I put a picture there so have with your example most apparently is not bringing any value. Is it because I’m not putting the rest of the grid values ? even though I have set the fields not mandatory?
– Jameson
put a pointbreak on the line, and check at runtime if it has any value
– Rovann Linhalis
+this{Adsintegrados.View.frmSlaveConsultProduct, Text: frmSlaveConsultProduct} Adsintegrados.View.frmSlaveConsultProduct this.Code 7 int this.Value 11 double Apparently in the selection form took the value now in the form that will receive it gets even more from the error of references -Object reference not defined for an instance of an object.
– Jameson
some object you are trying to use is null, just see which is
– Rovann Linhalis
does it have something to see with the bank ? because in the grid that receives it is only to list not done anything to insert in it. My thought was to add in the grid and save after ?
– Jameson