Hack Forums
[.NET] [Simple] Empty Italic Text - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] [Simple] Empty Italic Text (/showthread.php?tid=360883)



[Simple] Empty Italic Text - The-One - Apr 10, 2010

[img]http://i43.[censored].com/25ai41t.jpg[/img]

To:

[img]http://i43.[censored].com/jh8xfb.jpg[/img]

Needs:
  • Timer
  • Textbox

Codes:
Timer
Code
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        Dim fnt As Font
        fnt = TextBox1.Font
        If TextBox1.Text = "" Then
            TextBox1.ForeColor = Color.DimGray
            TextBox1.Font = New Font(fnt.Name, 9.75, FontStyle.Italic)
            TextBox1.Text = "Enter a title for your data here..."
        End If
    End Sub

Textbox.Click
Code
Private Sub TextBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Click
        If TextBox1.Text = "Enter a title for your data here..." Then
            Dim fnt As Font
            fnt = TextBox1.Font
            TextBox1.ForeColor = Color.White
            TextBox1.Font = New Font(fnt.Name, 9.75, FontStyle.Regular)
            TextBox1.Clear()
            Timer2.Stop()
        End If
    End Sub

Textbox.Leave
Code
Private Sub TextBox1_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Leave
        Timer2.Start()
    End Sub

I copyed it straight out one of my old projects, I hope you guys like it.
I made this code on my own.


* - Deathader - Apr 10, 2010

You don't need a timer for this. You can do it with the _changedtext event


* - The-One - Apr 10, 2010

(Apr 10, 2010 11:37 AM)Deathader Wrote:  You don't need a timer for this. You can do it with the _changedtext event

Okey, thanks for telling us.


* - Euras - Apr 10, 2010

Thanks for sharing. I remember when i started out, took me fucking ages to figure this out. Really helpful


* - The-One - Apr 10, 2010

(Apr 10, 2010 11:52 AM)The Major Wrote:  Thanks for sharing. I remember when i started out, took me fucking ages to figure this out. Really helpful

No Problem.


* - Charny - Apr 10, 2010

You can add this to the Leave event, when the textbox loses focus.