7
Answers

Object reference not set to an instance of an object.

Nel

Nel

12y
8.9k
1
Hi,

I want to check the value of the combobox in one form from another.
I have this code in button2_Click event


            Blagajna bl = (Blagajna)Application.OpenForms["Blagajna"];
            ComboBox cb = (ComboBox)bl.Controls["comboBoxVal"];
            String kom = (cb.SelectedItem).ToString();

and
Blagajna bl = new Blagajna();
in partial class definition.

I get this errorr: "Object reference not set to an instance of an object."

Could anybody help me please what is the problem with the code?

Thanks in advance.
Answers (7)