I am making an application that allows me to loan several equipment or tools, so I have created a loan form that registers the user and another form that searches for the product in question. The data that I would like to send would be the id of the product that is hidden, the name of the product and the quantity available.
The forms would be as follows.
Where I get the data.
That would be where I would receive them.
To retrieve the data from the database I use the following code.
public DataTable Buscar()
{
string ComandoSQL = "SELECT producto.id_prod, producto.nomb_prod, producto.precio_producto, producto.cantidad, producto.descripcion_prod, producto.id_categoria, categoria.nomb_categoria, producto.id_marca, marca.nomb_marca FROM producto, marca, categoria WHERE producto.id_categoria = categoria.id_categoria AND producto.id_marca = marca.id_marca";
return MiConexion.EjecutarSentencia(ComandoSQL);
}
And to retrieve the GridView data I use the following.
private void RecuperarDatos(object sender, DataGridViewCellMouseEventArgs e)
{
int fila = e.RowIndex;
id_producto = dtg_Busqueda.Rows[fila].Cells["id_producto"].Value.ToString();
nombre = dtg_Busqueda.Rows[fila].Cells["nomb_producto"].Value.ToString();
cantidad = dtg_Busqueda.Rows[fila].Cells["cantidad"].Value.ToString();
//enviar ok para que ventana padre pueda recibir
this.DialogResult = DialogResult.OK;
this.Dispose();
}
My question is, how do I put the recovered data in a new GridView in another form?