provided by: 
Originally published at Internet.comWe use a lot of controls like Buttons, Label, Checkbox, Radio Button, Text boxes, etc. while developing a GUI application. .NET provides a wide range of class, properties, and events for developing a complete GUI program by using the Control class of System.Windows.Forms namespace. In this part of our tutorial, I'll examine some of the important GUI Controls and their application in C#.
General Method for Adding Controls to Forms
1. Create an instance of the control. 2. Apply necessary properties like location, size, width, height, etc. 3. Finally, add the Control object to the Form's Controls Collection.
Using TextBox
Generally, Text boxes are of two classes, viz., Single line and multiple line boxes. Multiple line boxes have scroll bars. Also, users can enter more lines of text in them. The superclass of TextBox Control is TextBoxBase. It also provides functionalities for advanced controls like RichTextBoxes.
The following listing shows the usage of TextBox by examining important properties. Keep in mind that some of the properties derive from the TextBoxBase class. TextBox class provides only a limited set of properties. Listing 1.
using System; using System.Windows.Forms; using System.Drawing; public class Text: Form { // Text box object created TextBox t1 = new TextBox(); Text() { // Text box added this.Controls.Add(t1); t1.Location = new Point(50,50); t1.Size = new Size(200,50); t1.Text = "Class something to test"; t1.Multiline = true; t1.ScrollBars = ScrollBars.Vertical; t1.TextAlign = HorizontalAlignment.Center; t1.CharacterCasing = CharacterCasing.Upper; } public static void Main() { Application.Run(new Text()); } } ...
Read article at Internet.com site