Search This Blog

Tuesday, April 19, 2011

C# programming Basics part 2 - Buttons and Textboxes

First, let's make a button display text in a textbox.
1) select the textbox tool on the toolbar and make one on the form.
2) name the textbox txtboxdisplay, or anything else you can remember easily
3) select the button tool on the toolbar and add one to the form.
4) name the button bttndisplay or anything else you can easily remember.
now we can start programming
5) double click on the button, bringing you to the code screen
your programming for the task will go under "private void bttndisplay..." (typing line should start there automatically)
6) First you must tell the computer what you want to happen. In this case, because you want the textbox to display TEXT, you would write
textboxdisplay.text
^----(whatever you named the textbox)
7)Next enter the text you want to be displayed.
= "NICELY DONE!!!"
8) Add a semicolon!!! This must be done to every line of code

The final product is

txtboxdisplay.text = "Nicely Done!!!";

You can also make a message box (like those annoying error messages you get) appear by adding this line of code underneath the first line.

MessageBox.Show ("NICE JOB!!!");

Next time we will look at a very interesting and useful tool in C# programming. No Spoilers...

See you next time on Hayden@Earth

No comments:

Post a Comment