AznDevil92
AznDevil92

Reputation: 554

How can I make it so that a form's Text property will always equal a textbox's?

Is it possible to have the System.Windows.Forms Text property to equal the text in a certain textbox?

For example:

Is it possible to have "Name" automatically change to "The Vanguard Group, Inc."? And every other time when the Institution Name is different?

Maybe something like:
Me.Text = InstitutionNameTextBox.Text

Upvotes: 1

Views: 51

Answers (1)

Crono
Crono

Reputation: 10478

Yes, just handle Control.TextChanged event, like this:

Private Sub InstitutionNameTextBox_TextChanged(sender As Object, e As EventArgs) Handles InstitutionNameTextBox.TextChanged
    Me.Text = InstitutionNameTextBox.Text
End Sub

Of course this doesn't prevent Me.Text being set from elsewhere, in which case you may have a different value.

Upvotes: 2

Related Questions