Interacting with .NET WinForms, Part 2

We conclude our tutorial on working with Windows Forms in Microsoft.NET. Here, we'll examine some of the important GUI Controls and their application in C#.

provided by: 
Originally published at Internet.com


We 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
Related Articles
- An Active Server Pages Tutorial, Part 1
In a two-part introduction to the basics of plain ASP, the author walks you through the steps needed to employ scripts for creating dynamic Web pages.
- Encrypting a File Using .NET
- Interacting with .NET WinForms, Part 1
- Creating a Rounded Panel Control
- An Active Server Pages Tutorial, Part 2
- PostgreSQL Ends the Waiting Game
- Devexpress ASPxGridView
- C# Tips and Tricks
Regional Articles
- Interacting with .NET WinForms, Part 2 Alabama
- Interacting with .NET WinForms, Part 2 Alaska
- Interacting with .NET WinForms, Part 2 Arizona
- Interacting with .NET WinForms, Part 2 Arkansas
- Interacting with .NET WinForms, Part 2 California
- Interacting with .NET WinForms, Part 2 Colorado
- Interacting with .NET WinForms, Part 2 Connecticut
- Interacting with .NET WinForms, Part 2 DC
- Interacting with .NET WinForms, Part 2 Delaware
- Interacting with .NET WinForms, Part 2 Florida
- Interacting with .NET WinForms, Part 2 Georgia
- Interacting with .NET WinForms, Part 2 Hawaii
- Interacting with .NET WinForms, Part 2 Idaho
- Interacting with .NET WinForms, Part 2 Illinois
- Interacting with .NET WinForms, Part 2 Indiana
- Interacting with .NET WinForms, Part 2 Iowa
- Interacting with .NET WinForms, Part 2 Kansas
- Interacting with .NET WinForms, Part 2 Kentucky
- Interacting with .NET WinForms, Part 2 Louisiana
- Interacting with .NET WinForms, Part 2 Maine
- Interacting with .NET WinForms, Part 2 Maryland
- Interacting with .NET WinForms, Part 2 Massachusetts
- Interacting with .NET WinForms, Part 2 Michigan
- Interacting with .NET WinForms, Part 2 Minnesota
- Interacting with .NET WinForms, Part 2 Mississippi
- Interacting with .NET WinForms, Part 2 Missouri
- Interacting with .NET WinForms, Part 2 Montana
- Interacting with .NET WinForms, Part 2 Nebraska
- Interacting with .NET WinForms, Part 2 Nevada
- Interacting with .NET WinForms, Part 2 New Hampshire
- Interacting with .NET WinForms, Part 2 New Jersey
- Interacting with .NET WinForms, Part 2 New Mexico
- Interacting with .NET WinForms, Part 2 New York
- Interacting with .NET WinForms, Part 2 North Carolina
- Interacting with .NET WinForms, Part 2 North Dakota
- Interacting with .NET WinForms, Part 2 Ohio
- Interacting with .NET WinForms, Part 2 Oklahoma
- Interacting with .NET WinForms, Part 2 Oregon
- Interacting with .NET WinForms, Part 2 Pennsylvania
- Interacting with .NET WinForms, Part 2 Rhode Island
- Interacting with .NET WinForms, Part 2 South Carolina
- Interacting with .NET WinForms, Part 2 South Dakota
- Interacting with .NET WinForms, Part 2 Tennessee
- Interacting with .NET WinForms, Part 2 Texas
- Interacting with .NET WinForms, Part 2 Utah
- Interacting with .NET WinForms, Part 2 Vermont
- Interacting with .NET WinForms, Part 2 Virginia
- Interacting with .NET WinForms, Part 2 Washington
- Interacting with .NET WinForms, Part 2 West Virginia
- Interacting with .NET WinForms, Part 2 Wisconsin
- Interacting with .NET WinForms, Part 2 Wyoming
Related Articles
- An Active Server Pages Tutorial, Part 1
In a two-part introduction to the basics of plain ASP, the author walks you through the steps needed to employ scripts for creating dynamic Web pages.
- Encrypting a File Using .NET
- Interacting with .NET WinForms, Part 1
- Creating a Rounded Panel Control
- An Active Server Pages Tutorial, Part 2
- PostgreSQL Ends the Waiting Game
- Devexpress ASPxGridView
- C# Tips and Tricks

Rss   Delicious   Digg   Add To My Yahoo   Add To My Google   Bookmark   Search Plugin

Topics:
Architecture & Design Languages & Tools Project Management Web Services
Database Microsoft & .NET Security Wireless
Java Open Source Techniques XML