Hi guys I'm new here and willing to help in the future. Right now I'm developing a program, and I need to store the data selected in a combobox in a global variable, and use it in another form.
Basically I have a combobox where you select a company, these companies are loaded in the combo from a previous data base.
I want that when the user clicks the accept button, the selected company name that comes from the database gets stored in a variable.
It already does it, but only with the company that first appears in the combobox, because when the form loads this is preselected, and the button only hides and shows the next form.
I want that when the button is clicked, the selected data gets stored.
I have this already:
DataTable ds = new DataTable();
sda.Fill(ds);
myConnection.Close(); //Cierra la conexion
cmbempre.DataSource = ds;
cmbempre.DisplayMember = "cod_empresa";
cmbempre.ValueMember = "cod_empresa";
GlobalClass.GlobalVar1 = cmbempre.SelectedValue.ToString();
Skipping the conection string and adapter, and this is setted in the public partial class