How to show text in combobox when no item selected?

前端 未结 16 1364
太阳男子
太阳男子 2020-11-30 06:39

C# & .Net 2.0 question (WinForms)

I have set of items in ComboBox and non of them selected. I would like to show a string on combo \"Pl

16条回答
  •  无人及你
    2020-11-30 07:06

    One line after form InitializeComponent();

    cbo_MyDropBox.Text = "Select a server...";
    

    You only need it once right? All you need to do if a pick is mandatory is check if the box index != -1. Could anyone elaborate why the other answers jump through hoops to get this going?

    The only thing I'm missing here is having just this initial text grayed out. If you really want that just use a label in front and turn it off once the index is changed.

提交回复
热议问题