Text of combobox to set

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Praveen Raj V
    New Member
    • Sep 2010
    • 11

    Text of combobox to set

    I have changed the DropDownStyle property of comboBox to DropDownList.
    I'm unable to change the text property for comboBox.
    suggest an idea.
    Code:
    comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
    comboBox1.Text = "Select an item";//unable to change this property.
  • GaryTexmo
    Recognized Expert Top Contributor
    • Jul 2009
    • 1501

    #2
    When the combo box is a dropdown list, I don't think you can arbitrarily set the text. The combobox can only select the existing values in the list via SelectedIndex.

    I see what you're trying to do though, and I think it will involve a bit of trickery on your part to get that behaviour. You could either leave it as a DropDown with that text until an item is selected, or you could have "Select an item" as an item until another one is picked, then remove that item.

    I'm sure there are other solutions that might suit you better, play around and see what you come up with :)

    Comment

    • peochei
      New Member
      • Oct 2010
      • 12

      #3
      You may also be interested in watermark effect on ComboBox control.

      Here's ready-to-use implementation:
      Read writing from Aaron Lerch on Medium. Life enthusiast. I enjoy people and technology. Nayebi Lingala. CTO at Digible. Previously platform and infra leader at Netflix and InVision.

      Comment

      Working...