Jordan King
Jordan King

Reputation: 11

How to assign a value to a textbox at program start

i am creating a project for my class (C# in visual studio) that works as a token dispensing machine.

The user clicks on a button that changes the textbox with the label number of quarters from 0 to 1 and continues to increase that number by 1 each time the user clicks the button, the next textbox with the label number of tokens starts at 100 and decreases by 1 each time the user clicks the button mentioned above.

I have the code correct for the most of that, my question is how to get the textboxes to display the numbers 100 for number of tokens and 0 for the number of quarters when the program STARTS. Not when the button is clicked.

Upvotes: 0

Views: 2064

Answers (1)

Sven Grosen
Sven Grosen

Reputation: 5636

There are two simple ways to accomplish this for a Win Forms application:

  1. When the designer is open, select the given textbox and look at the Properties window. You'll see a property called Text, set it to your desired value.
  2. In the code-behind for your form, in the constructor or Form_Load event, you can programmatically set the values using the form of textBox.Text = "[DESIRED_VALUE]";

Upvotes: 1

Related Questions