In my application I have one text box for entering user name. If text is empty i want to show "Enter User name here" in same text box in gray color. Is there any property like this for text box. Like in Firefox browser if URL field is empty it will show "Go to a web site" In gray color
Thanks
I know this may be an old thread, but I thought I'd answer it just in case anyone else stumbled across it.
First declare the following (you may need to import System.Runtime.InteropServices
)
<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As Integer, <MarshalAs(UnmanagedType.LPWStr)> ByVal lParam As String) As Int32
End Function
Then call the following (change as needed):
SendMessage(Me.textbox1.Handle, &H1501, 0, "Enter User name here")
Assuming you mean Windows Forms, take a look at this question.
Basically, you need to call a WinAPI SendMessage
function for the control with EM_SETCUEBANNER
value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With