locked
Add combobox selectedvalue to entity object RRS feed

  • Question

  • How can I add a combobox selectedvalue to entity object? I've this code:

            private void button2_Click(object sender, EventArgs e)
            {
                items it = new items();
                it.itemName = itemNameTextBox.Text.ToString();
                it.itemUnitId = itemUnitIdComboBox.SelectedItem();
                valinor.AddToitems(it);
                valinor.SaveChanges();             
            }

    I got error message:

    Error    1    Non-invocable member 'System.Windows.Forms.ComboBox.SelectedItem' cannot be used like a method.

    Wednesday, September 5, 2012 8:13 AM

Answers

  • Hi,

    itemUnitIdComboBox.SelectedValue;

    Is a property not a method. Remove the '()'.

    Hope this helps!


    Best Regards,
    Carlos Sardo

    Wednesday, September 5, 2012 10:00 AM