0

Believe me it is a question.

Hi,

I am a VB Beginner as you might have understood from the title. I wanted to make a fashionable Login Form with the Textboxs that follow these:

The default text in the UserNameTB would be "UserName Goes Here" in a Gray Color.

When the User clicks the UserNameTB the text would changes to "" and the color to Black.

Please study these code to get other conditons:

Private Sub UserName_TB_GotFocus(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UserName_TB.GotFocus
        If UserName_TB.Text = "UserName" Then
            UserName_TB.Text = ""
            UserName_TB.ForeColor = Color.Black
        End If
    End Sub

    Private Sub UserName_TB_LostFocus(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UserName_TB.LostFocus
        If UserName_TB.Text = "" Then
            UserName_TB.Text = "UserName"
            UserName_TB.ForeColor = Color.Gray
        End If
    End Sub

This works fine with a Simple TextBox But when I set the property 'UseSystemPasswordChar' to True (for the password) there is an exception.

You may write an article on this topic as I didn't found any.

Thank You.

Community
  • 1
  • 1
  • 1
    the term you are looking for is Cue or Text Cue. Possible dupe of [Watermark TextBox in WinForms](http://stackoverflow.com/q/4902565/1070452) which also did not know the term – Ňɏssa Pøngjǣrdenlarp Mar 02 '15 at 14:37
  • 2
    [SO] is not a code writing service, but you mention an error without anything about what kind of error (exception type, message, …). Equally you fail to define what you mean by either "fashionable" or "attractive". – Richard Mar 02 '15 at 14:38
  • Sorry for that Richard, but I thought that you may understand the words "fashionable" or "attractive". Stack Overflow is not a code writing service, very true but I had not asked for ready-made codes. Any ways I have got the answer. Thank you – Vinayak D.Gaikwad Mar 07 '15 at 05:21

2 Answers2

1

You need a placeholder. This link has all the information you need to custom code one.

http://www.vbasic.net/how-to-create-a-placeholder-in-visual-basic-net/

Mike
  • 13
  • 4
0

I think suggest your MaskedTextBox control instead of Textbox if you're doing a login form for instance. You can do data validation with it.

This is a very helpful Link: http://www.functionx.com/visualstudio/propwnd/mask1.gif

Amen Jlili
  • 1,884
  • 4
  • 28
  • 51