-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTextBoxUtilities.cs
More file actions
32 lines (19 loc) · 805 Bytes
/
TextBoxUtilities.cs
File metadata and controls
32 lines (19 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using Gsemac.Win32.Native;
using System;
using System.Windows.Forms;
namespace Gsemac.Forms {
public static class TextBoxUtilities {
// Public members
public static bool SetPlaceholderText(TextBox textBox, string placeholderText) {
if (textBox is null)
throw new ArgumentNullException(nameof(textBox));
if (placeholderText is null)
placeholderText = string.Empty;
// Note that the flags required for this feature are available only on Windows Vista or newer.
if (Environment.OSVersion.Version < new Version(6, 0))
return false;
User32.SendMessage(textBox.Handle, Constants.EM_SETCUEBANNER, (IntPtr)0, placeholderText);
return true;
}
}
}