Designer Attributes

function OpenWin(url, w, h) { if(!w) w = 400; if(!h) h = 300; window.open(url, "_new", "width=" + w + ",height=" + h + ",menubar=no,toobar=no,scrollbars=yes", true); }

Attributesplay a large role in every facet of .NET, from XML serialization to control development. The PropertyGrid relies heavily on custom attributes for object properties that it uses to determine the default value, determine whether the property is browsable, and make many other choices. Attributes are used to control the PropertyGrid and the code serializer, and for defining the UITypeEditor for a property, the designer for a component, and the category for a designer, among other things. The common case for attributes deals with interaction with the PropertyGrid and specifying the category, description, browsable, and type converter attributes. Figure 5.3 shows how attributes are used to control the PropertyGrid.

Figure 5.3. The PropertyGrid.

figure 5.3. the propertygrid.

The use of attributes provides a powerful and expressive manner in which to decorate a component with additional functionality and services without having to inherit or write custom code. As a general rule, look for an attribute first, and then write code. Chances are there is an attribute that will accomplish that task without requiring you to write any code. The subject of attributes will continue to come up throughout this book. With each new attribute used, an explanation of its use will be covered.



    .NET Windows Forms Custom Controls
    User Interfaces in VB .NET: Windows Forms and Custom Controls
    ISBN: 1590590449
    EAN: 2147483647
    Year: 2002
    Pages: 74

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net