Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

[Simple] Empty Italic Text

[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.
FR1908
You don't need a timer for this. You can do it with the _changedtext event
(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.
FR1908
Thanks for sharing. I remember when i started out, took me fucking ages to figure this out. Really helpful
(Apr 10, 2010 11:52 AM)Euras Wrote:  Thanks for sharing. I remember when i started out, took me fucking ages to figure this out. Really helpful

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


Possibly Related Threads...
Thread / Author Replies Views Last Post
by Neo_KaiserAug 10, 2025 02:36 PM 0 107 Aug 10, 2025 02:36 PM
Last Post: Neo_Kaiser
[C#] by notahackermanApr 27, 2020 10:05 PM 14 340 Apr 27, 2020 10:05 PM
Last Post: Accord
[Python] by FaberCastellMar 30, 2019 12:23 PM 4 124 Mar 30, 2019 12:23 PM
Last Post: Oracle