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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. combobox datasource

combobox datasource

Scheduled Pinned Locked Moved C#
question
2 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.
  • B Offline
    B Offline
    brain2cpu
    wrote on last edited by
    #1

    It is just wierd, I have something like: ArrayList al1 = .... //filled with some data combobox1.DataSource = al1; it is all OK. BUT, later I have to change the contents of the combobox, so: ArrayList al2 = .... //filled with something else combobox1.DataSource = al2; here cames up with a null DataSource (al2 is correct and no errors are shown). I also tried to get the ArrauList back: ArrayList al = (ArrayList)combobox1.DataSource; al.Add("..."); ..... but nothing changed. What could be wrong ? I would prefer the first approach.

    C 1 Reply Last reply
    0
    • B brain2cpu

      It is just wierd, I have something like: ArrayList al1 = .... //filled with some data combobox1.DataSource = al1; it is all OK. BUT, later I have to change the contents of the combobox, so: ArrayList al2 = .... //filled with something else combobox1.DataSource = al2; here cames up with a null DataSource (al2 is correct and no errors are shown). I also tried to get the ArrauList back: ArrayList al = (ArrayList)combobox1.DataSource; al.Add("..."); ..... but nothing changed. What could be wrong ? I would prefer the first approach.

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      varadii wrote: What could be wrong ? I've not double checked this, so this may not be right.... When you assign something to the ComboBox.DataSource the ComboBox knows that the source of the data is different and will update its contents accordingly. However if you just add an element to the array the ComboBox knows nothing of this and won't update. So, you have to tell the ComboBox that the array has changed. (Possibly by just assigning the Array back to the datasource) Does this help?


      "You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar Coming soon: The Second EuroCPian Event

      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