Text box shadowing
-
We see more and more text boxes that contain a faded text to help the user enter the right information. A good example you could have a text box wuith a label "Email" and faded in the text box we could have something like "YourAddress@yourdomain.com" to help the user. Normally as soon as data in entered , this information disapears and is never seen again. I think it is called shadowing. .NET Windows forms doesn't seem to support this, or did I miss something.
-
We see more and more text boxes that contain a faded text to help the user enter the right information. A good example you could have a text box wuith a label "Email" and faded in the text box we could have something like "YourAddress@yourdomain.com" to help the user. Normally as soon as data in entered , this information disapears and is never seen again. I think it is called shadowing. .NET Windows forms doesn't seem to support this, or did I miss something.
A website that has a control like what you are looking for is: XP Common Controls (XPCC)[^] This site has a control that can give the shadowed text called a XPCueBannerExtender. The description on the site: The CueBannerExtender allows you to display a grayed text inside a textbox or group box that will vanish when the control gets the focus. Because this is an extender control you can simply place it onto your form and add the CueBannerText to display to each textbox and groupbox you wish. However if you do use other controls on this site such as the XPLetterBox and XPLoginEntry. Please consider using my XP Logon Control[^] that is based off of both of the controls and adds some other user interface enhancements.
Regards, Thomas Stockwell Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Visit my homepage Oracle Studios[^]
-
We see more and more text boxes that contain a faded text to help the user enter the right information. A good example you could have a text box wuith a label "Email" and faded in the text box we could have something like "YourAddress@yourdomain.com" to help the user. Normally as soon as data in entered , this information disapears and is never seen again. I think it is called shadowing. .NET Windows forms doesn't seem to support this, or did I miss something.
This effect can be fairly easily done. Use the designer to add some sample text like email address and change the coloer to your light grey color. The designer will look like something lke:
Me.TextBox1.ForeColor = System.Drawing.Color.Silver Me.TextBox1.Text = "Sample text"
As soon as the user starts to type in the text box you want the text to clear and the color to change. So handle a couple possible events like this:
Private m\_bFirst As Boolean = True Private Sub TextBox1\_TextChanged(ByVal sender As System.Object, \_ ByVal e As System.EventArgs) Handles TextBox1.TextChanged If m\_bFirst Then 'clear the text TextBox1.Text = "" TextBox1.ForeColor = Color.Black End If End Sub Private Sub TextBox1\_MouseDown(ByVal sender As System.Object, \_ ByVal e As System.Windows.Forms.MouseEventArgs) \_ Handles TextBox1.MouseDown If m\_bFirst Then 'clear the text TextBox1.Text = "" TextBox1.ForeColor = Color.Black End If End Sub
I have just made these changes to the form where I was using the text box. If you wanted to use this style more then once you could make a custom control.
-
This effect can be fairly easily done. Use the designer to add some sample text like email address and change the coloer to your light grey color. The designer will look like something lke:
Me.TextBox1.ForeColor = System.Drawing.Color.Silver Me.TextBox1.Text = "Sample text"
As soon as the user starts to type in the text box you want the text to clear and the color to change. So handle a couple possible events like this:
Private m\_bFirst As Boolean = True Private Sub TextBox1\_TextChanged(ByVal sender As System.Object, \_ ByVal e As System.EventArgs) Handles TextBox1.TextChanged If m\_bFirst Then 'clear the text TextBox1.Text = "" TextBox1.ForeColor = Color.Black End If End Sub Private Sub TextBox1\_MouseDown(ByVal sender As System.Object, \_ ByVal e As System.Windows.Forms.MouseEventArgs) \_ Handles TextBox1.MouseDown If m\_bFirst Then 'clear the text TextBox1.Text = "" TextBox1.ForeColor = Color.Black End If End Sub
I have just made these changes to the form where I was using the text box. If you wanted to use this style more then once you could make a custom control.