Thursday, September 20, 2012

Windows Form Controls (Part 1)

Since you work on the windows form application, you may have noticed that when an empty form opens up there pops up a tab named toolbox on the left side of the IDE. In this toolbox you can find different types of windows controls to work with in your application. So why don't we discover some of this controls and their properties, attributes and methods.

So here we go....
  1. Start the IDE.
  2. Create a New Project. Name it WindowsControlsTutorials.
  3. Right Click on the Form and choose Properties. On the Right Side of the IDE a window will popup showing different properties of the Form. This properties can be changed at any time manually or through the code.
  4. Try to goofing around with the properties by changing. You will see the changes on the Form.
  5. So let me change the Text of the Form1. Scroll to the text region and set the Text to Windows Controls instead of Form1.
  6. You will see the Header Text Changed to Windows Controls from Form1.
  7. Now drag some controls on the Form.
  8. Drag three labels and release them on the Form. Change the Text property of them to First Name, Middle Name, Last Name.
  9. Drag three textBox from the toolbox and arrange them with the labels. And add a button at the bottom. Change the Text property to Show.
  10. Now double click the show button. It will generate a click event method. There are lots of events available for a controls. Try experimenting with them. They are arranged under the thunderbolt icon of the Properties window.
  11. In the method type
  12. MessageBox.Show(textBox1.Text+" "+textBox2.Text+" "+textBox3.Text);
  13. Click on debug button and give First, Middle and Last name on the textBox and press Show. 
  14. A messageBox will popup and will show your full name.Like this.

No comments:

Post a Comment