Sponsored Ad

Monday, September 28, 2009

C# Controls

Windows programmers have a wide variety of controls to choose from in the System.Windows.Forms namespace in .NET's Framework class library. You accept controls as simple as Label, TextBox, and CheckBox, as able-bodied as controls as adult as the MonthCalendar and ColorDialog controls. hese Windows controls are more than enough for most applications; however, sometimes you charge controls that are not accessible from the accepted library. . In these circumstances, you have to roll up your sleeves and write your own. This article shows you how to develop a custom control with C# and presents a simple custom control.

Before you start writing the first line of code for your custom control,you should familiarize yourself with two classes in the System.Windows.Forms namespace: Control and UserControl. The Control chic is important because it is the ancestor chic of Windows beheld components. Your custom chic will be a descendent of the Control chic as well. Your custom controls, however, don't normally inherit directly from the Control class. Instead, you extend the UserControl class. The aboriginal two sections of this commodity altercate these two classes. In the final section, you'll body your own custom control, the RoundButton control.

//specify the namespace in which the control resides
namespace Test.Control
{
      //specify the name spaces of other classes that are commonly referenced
      using System.WinForms;
      //the control definition and implementation
      public class MyControl : System.WinForms.RichControl
      {
      }
}

0 comments:

Post a Comment

Sponsored Ad

Website Update

Followers