Nel

Nel

  • NA
  • 716
  • 1m

Object reference not set to an instance of an object.

Jun 25 2012 7:08 AM
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)