I have two forms, in one I have a ComboBox
which in the event Load
uploads data from a database sql server making a query.
To add more data I would have to modify my query, which I added a button in front of ComboBox
, when I clicked it I opened a small form where all the records of a sql server table are. I want that when one is selected I add it to the combo of the first form, how can I implement it?
da.Fill(TABLA);
cmbProductos.DataSource = null;
cmbProductos.DisplayMember = "Nombre";
cmbProductos.ValueMember = "id";
cmbProductos.DataSource = TABLA;
This way I load my data in ComboBox
at first, this would only work while I do not close the main form, because when it is reloaded only the query data will appear ...
So I get the fields I want to add to the other form:
string concepto;
string id;
filaSeleccionada = dgvAgregarCombo.CurrentCell.RowIndex;
concepto = dgvAgregarCombo.Rows[e.RowIndex].Cells["CONCEPTO"].Value.ToString();
id = dgvAgregarCombo.Rows[e.RowIndex].Cells["ID_CONCEPTO"].Value.ToString();