C#:APPS - Grey out and disable some of the elements in combo box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • y2ktan
    New Member
    • Feb 2008
    • 6

    C#:APPS - Grey out and disable some of the elements in combo box

    Hi Guys and Girls,

    I am building a windows application using VS2005, C#.net. Now, I have a combo box that contains a collection of elements.

    Thus, I want to grey out some of the elements in the combo box. Alas, I cannot find any properties or forum that able to help me to grey out and disable some of the elements in combo box.

    Does anyone have any idea on how to grey out and disable the combo box's elements. Your help is really appreciated.

    Thank you and have a nice day.
  • nateraaaa
    Recognized Expert Contributor
    • May 2007
    • 664

    #2
    Originally posted by y2ktan
    Hi Guys and Girls,

    I am building a windows application using VS2005, C#.net. Now, I have a combo box that contains a collection of elements.

    Thus, I want to grey out some of the elements in the combo box. Alas, I cannot find any properties or forum that able to help me to grey out and disable some of the elements in combo box.

    Does anyone have any idea on how to grey out and disable the combo box's elements. Your help is really appreciated.

    Thank you and have a nice day.
    Why grey them out? Just populate the combo box with the items that will be available to the user.

    Nathan

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      Originally posted by nateraaaa
      Why grey them out? Just populate the combo box with the items that will be available to the user.

      Nathan
      Yeah, I would recomend that.
      I'm not even sure it's POSSIBLE to "disable" some entries in a combo box. I've never seen it done.

      ALTHOUGH, if you put an event handler on the selectedindex change event, you could maybe mimic the behaviour.
      In it you would:
      Check to see if the new index refers to a valid (read: not disabled) entry. If it's valid, update a state variable with the good index and exit the function.
      If it's an INVALID index (disabled entry), change the index to the last "good" index saved in the state variable.

      Comment

      Working...