Entity Framework ComboBox issue !!
-
Hello all and let me explain my problem briefly in Windows Forms application. If any of you read Julia Lerman`s book, i am basicly implementing the techniques that are explained there but one thing i couldn`t solve. To make it simple i have two tables with one to many relationship, like customer and address. I add the customer to the datasource and change the address navigation property to combobox. I drag name, surname and adress to the Forms. This is how i do databinding
CustomerEntities context = new CustomerEntities();
List<adress> myadresses = context.addresses.ToList();CustomerBindingSource.DataSource = context.customers.Execute(System.Data.Objects.MergeOption.AppendOnly);
AddressBindingSource.DataSource = myaddresses;Now as the book says i set the datasource of the addreess combobox to AddressBindingSource in UI then set displaymember, value and selectedItem. Everything works fine except that display member of the combobox doesn`t display porperly. It diplays as MyAppName.Address, meaning object itself..What am i missing please help me
-
Hello all and let me explain my problem briefly in Windows Forms application. If any of you read Julia Lerman`s book, i am basicly implementing the techniques that are explained there but one thing i couldn`t solve. To make it simple i have two tables with one to many relationship, like customer and address. I add the customer to the datasource and change the address navigation property to combobox. I drag name, surname and adress to the Forms. This is how i do databinding
CustomerEntities context = new CustomerEntities();
List<adress> myadresses = context.addresses.ToList();CustomerBindingSource.DataSource = context.customers.Execute(System.Data.Objects.MergeOption.AppendOnly);
AddressBindingSource.DataSource = myaddresses;Now as the book says i set the datasource of the addreess combobox to AddressBindingSource in UI then set displaymember, value and selectedItem. Everything works fine except that display member of the combobox doesn`t display porperly. It diplays as MyAppName.Address, meaning object itself..What am i missing please help me
Not sure I fully understood your needs. But try to override the ToString() method in order to select what's you want to display.
-
Not sure I fully understood your needs. But try to override the ToString() method in order to select what's you want to display.