I wanna use watermark in Text Boxes of my Windows Form using c#?
I have found this link in stackoverflow. But I really could not figure out how to use in my windows application.
class WatermarkTextBox : TextBox
{
private const uint ECM_FIRST = 0x1500;
private const uint EM_SETCUEBANNER = ECM_FIRST + 1;
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, uint wParam, [MarshalAs(UnmanagedType.LPWStr)] string lParam);
private string watermarkText;
public string WatermarkText
{
get { return watermarkText; }
set
{
watermarkText = value;
SetWatermark(watermarkText);
}
}
private void SetWatermark(string watermarkText)
{
SendMessage(this.Handle, EM_SETCUEBANNER, 0, watermarkText);
}
}
Please help how to use SendMessage Method Or Suggest me any other (easy) way to use watermark.