Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Text box shadowing

Text box shadowing

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharpwinformscomhelptutorial
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Johnny 0
    wrote on last edited by
    #1

    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.

    T L 2 Replies Last reply
    0
    • J Johnny 0

      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.

      T Offline
      T Offline
      Thomas Stockwell
      wrote on last edited by
      #2

      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[^]

      1 Reply Last reply
      0
      • J Johnny 0

        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.

        L Offline
        L Offline
        Leah_Garrett
        wrote on last edited by
        #3

        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.

        J 1 Reply Last reply
        0
        • L Leah_Garrett

          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.

          J Offline
          J Offline
          Johnny 0
          wrote on last edited by
          #4

          I wanted to avoid wriring but it's not too long to do so let's get busy !

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups