Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Entity Framework ComboBox issue !!

Entity Framework ComboBox issue !!

Scheduled Pinned Locked Moved C#
helpwinformsdesignsaleslearning
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Minimech
    wrote on last edited by
    #1

    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

    M 1 Reply Last reply
    0
    • M Minimech

      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

      M Offline
      M Offline
      Migounette
      wrote on last edited by
      #2

      Not sure I fully understood your needs. But try to override the ToString() method in order to select what's you want to display.

      M 1 Reply Last reply
      0
      • M Migounette

        Not sure I fully understood your needs. But try to override the ToString() method in order to select what's you want to display.

        M Offline
        M Offline
        Minimech
        wrote on last edited by
        #3

        Thanks, i override the tostring method of the entity object to get the work done..When i use listbox nothing is needed to display correctly but with texbox this is needed i guess, thanks again

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups