Good day I am developing a windows form with a grid, which is loaded by means of a database, as I can open a new windows form by double clicking on any record inside the datagridview.
Thanks for the help.
Good day I am developing a windows form with a grid, which is loaded by means of a database, as I can open a new windows form by double clicking on any record inside the datagridview.
Thanks for the help.
Hello for that you must program in the event "dataGridView1_CellDoubleClick", capture the selected row and pass each of the elements to the form you want to open. I suppose you want to open a form with the data selected from the datagridview row, right?
If that is what you want, the only thing you should do is the following: Suppose you have a datagridview which as you mention in your question you fill in from your database, for example with the product table, which contains 3 fields (Code, Name and Price), then what you should do as I said before is to program the event "celldoubleclick" of the datagrid, you should use something like this:
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
FormSecundario frm = new FormSecundario(); //Instanciamos el Form que abriremos
frm.txtCodigo.Text = dataGridView1.CurrentRow.Cells[0].Value.ToString();
frm.txtProducto.Text = dataGridView1.CurrentRow.Cells[1].Value.ToString();
frm.txtPrecio.Text = dataGridView1.CurrentRow.Cells[2].Value.ToString();
frm.Show(); //Mostramos el Form que deseamos abrir.
}
That is the event of the gridview that you must program, you must call your formsecundario and pass to each one of its controls the data of the product, you must bear in mind that the controls where you will show the data of the product must have the property "modifiers "= Public so you can access from the main form, with that everything would be ready.