Home > Articles > Programming > C#

Events and Properties for Composite Custom Controls in C#Builder

  • Print
  • + Share This
By adding properties and events, you can extend the value of controls and make them easier for developers to work with in an integrated development environment (IDE). Opening opportunities for developers to work with visual design tools promotes control reuse and ultimately enhances productivity. In this article, you'll learn how to achieve these goals by adding events and properties to composite custom controls in C#Builder.
From the author of

When building reusable controls in ASP.NET, you need the ability to add custom events and properties for manipulation through an integrated development environment (IDE). This article guides you through the maze of building an ASP.NET composite custom control that exposes events and properties that you can access in the C#Builder IDE.

Introduction to ASP.NET Composite Custom Controls

An ASP.NET composite custom control is much like a user control (see my previous InformIT article "Crafting ASP.NET User Controls in C#Builder"), but is built and deployed differently:

  • You build user controls by adding constituent controls in the GUI designer.

  • You add constituent controls to a composite control only in code.

Another difference between the two control types is that user controls are files that belong to a single project. To share a user control between projects, you have to copy the file, which limits maintainability because you then have multiple copies to keep up to date. The advantage of composite custom controls is that they're compiled to a dynamic link library (DLL), which can be shared among multiple projects.

While the application in this article creates a composite custom control, the primary focus is describing how to implement events and properties for controls in general. With C#Builder, you can modify control behavior during design time by configuring the control with the Object Inspector. With one tab for properties and another for events, all you have to do is select a control on the design surface and all of its properties and events are available for customizing in the Object Inspector. This article explains how to make this feature work for your controls.

NOTE

This article describes how to build a composite custom control with Borland C#Builder for Microsoft .NET. However, once the control is built, you can use it in any other IDE, such as Microsoft Visual Studio .NET.

  • + Share This
  • 🔖 Save To Your Account