How to show text in combobox when no item selected?

前端 未结 16 1359
太阳男子
太阳男子 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:12

    I can't see any native .NET way to do it but if you want to get your hands dirty with the underlying Win32 controls...

    You should be able to send it the CB_GETCOMBOBOXINFO message with a COMBOBOXINFO structure which will contain the internal edit control's handle. You can then send the edit control the EM_SETCUEBANNER message with a pointer to the string. (Note that this requires at least XP and visual styles to be enabled.

提交回复
热议问题