swdev
swdev

Reputation: 5147

How to make VB.NET TextBox field to have FlatAppearance effect such as in Button?

First of all, I hope I state my problem correctly. I am in the making of creating a database desktop application using VB.NET. I want my UI to have similiarity the same as Microsoft Money. By this, now I want to make all my textbox to behave this way :

That's all. I recognize that in TextButton, we have FlatAppearance, so we can tweak all Button to behave like this. But the same is not happened for TextField.

Is there any simple alternative of solving this issue?

Thanks,

Eko

Upvotes: 0

Views: 1410

Answers (1)

SeriousSamP
SeriousSamP

Reputation: 436

You could try something like this.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        For Each control As Control In Me.Controls ' Check every control
            If control.GetType().Equals(GetType(TextBox)) Then ' Proceed if it is a TextBox
                Dim textBox As TextBox = control ' So we have the right type
                AddHandler textBox.MouseEnter, Sub() textBox.BorderStyle = BorderStyle.FixedSingle ' Mouse over state
                AddHandler textBox.MouseLeave, Sub() textBox.BorderStyle = BorderStyle.None ' Mouse away state
                textBox.BorderStyle = BorderStyle.None ' Set initial state
            End If
        Next
End Sub

Looping through every control at the beginning may not be the best way of doing this, but it is the easiest way to get a working example.

If you need anything else just say,
Sam.

Upvotes: 1

Related Questions