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. ComboBox bug?

ComboBox bug?

Scheduled Pinned Locked Moved C#
helpquestion
2 Posts 1 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.
  • T Offline
    T Offline
    t800t8
    wrote on last edited by
    #1

    I have a combo box whose items are load from a List (List is not empty). I already set SelectedIndex = 0 to choose the first item in code. But at runtime, when I click the arrow, drop down list appear and I don't select any item, SelectedIndex will be set to -1. If I select an item, SelectedIndex will be other than -1. I think SelectedIndex should be 0 even I click the arrow and don't select any item. Is there any body has same problem?

    I'm ... a fan of Manchester United a fan of Ozzy Osbourne a King of Nothing

    T 1 Reply Last reply
    0
    • T t800t8

      I have a combo box whose items are load from a List (List is not empty). I already set SelectedIndex = 0 to choose the first item in code. But at runtime, when I click the arrow, drop down list appear and I don't select any item, SelectedIndex will be set to -1. If I select an item, SelectedIndex will be other than -1. I think SelectedIndex should be 0 even I click the arrow and don't select any item. Is there any body has same problem?

      I'm ... a fan of Manchester United a fan of Ozzy Osbourne a King of Nothing

      T Offline
      T Offline
      t800t8
      wrote on last edited by
      #2

      It's a bug. I have a list contains several items of Tag(int id, string name). I use "id" as ValueMember and "name" as DisplayMember. If the first item has name is an empty string, the problem will appear. When you click the arrow, seems M$ implemented to select text value to get the index. If you have an empty string, it cannot select anything and the returned index will be -1.

      I'm ... a fan of Manchester United a fan of Ozzy Osbourne a King of Nothing

      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