Watermark TextBox in WinForms

前端 未结 10 2080
说谎
说谎 2020-11-22 00:35

Can anyone point me to a good implementation of a basic Windows Forms TextBox that will initially show watermark text that disappears when the cursor enters it? I think I ca

10条回答
  •  天命终不由人
    2020-11-22 01:10

    Using WinForms on .NET Core:

    This has been greatly simplified in .NET Core. You can directly add placeholder text by modifying the new PlaceholderText Property of the TextBox.

    public virtual string PlaceholderText { get; set; }
    

    Note that you would probably still have to edit the ForeColor if you want to get a colored Placeholder Text. The PlaceholderText field is visible when the Text field is null or empty.

提交回复
热议问题