C#
  Home arrow C# arrow C# Simplified, part 7: Working with WinFor...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
C#

C# Simplified, part 7: Working with WinForm Controls
By: Anand Narayanaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 12
    2005-06-14

    Table of Contents:
  • C# Simplified, part 7: Working with WinForm Controls
  • Working with Checkboxes
  • Working with RadioButtons
  • Working with Labels
  • Working with Combo boxes
  • Working with List boxes

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    C# Simplified, part 7: Working with WinForm Controls


    (Page 1 of 6 )

    In the previous article, we saw the fundamentals behind programming with .NET WinForms. In this article, we will examine the working of some of the important controls, which are used in normal windows applications, with the help of examples.

    Working with Buttons

    With the help of the Button control, you can perform some kind of activity on your application. For instance, clicking a button can generate a MessageBox or another Form. Further, you can sometimes add records to a database with the click of a button. The base class of Button is ButtonBase. This is also the base class for CheckBox and RadioButton controls. Listing 7.1 illustrates the usage of this important control:

    Listing 7.1

    001: // MyButton.cs
    002: // -----------
    003: using System;
    004: using System.Drawing;
    005: using System.Windows.Forms;
    006:
    007: public class MyButton:Form
    008: {
    009:   Button b1 = new Button();
    010:
    011:   MyButton()
    012:   {
    013:     b1.Text = "OK";
    014:     b1.BackColor = Color.Silver;
    015:     b1.Size = new Size(60,30);
    016:     b1.Location = new Point(50,40);
    017:     b1.FlatStyle = FlatStyle.Popup;
    018:     this.Controls.Add(b1);
    019:     this.Text = "Button Control Demo";
    020:   }
    021:
    022:   public static void Main()
    023:   {
    024:     MyButton b = new MyButton();
    025:     Application.Run(b);
    026:   }
    027: }

    Output

    Figure 7.1

    You will note that nothing will happen if you click the buttons. This is because we didn't applied events. We will explore this concept in a later part of this article.

    More C# Articles
    More By Anand Narayanaswamy


     

    C# ARTICLES

    - Coding a CRC-Generating Algorithm in C
    - Cyclic Redundancy Check
    - Handling Methods and Functions
    - Destroying Objects in C#
    - Creating Objects in C-Sharp
    - Classes and Objects
    - Programming Languages: Managed versus Native
    - LINQ-to-MySQL with DbLinq in C#
    - Working with Dates and Times in C#
    - Generics, Dictionaries, and More
    - More About Generics
    - Working with C# Collections
    - Generics
    - C# and XML
    - Pointers and Arrays in C#





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek