Chapter 3 - Designer Basics

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); }

IN THIS CHAPTER

  • The ControlDesigner Base Class

  • DesignerAttribute

  • The IconButton Designer

  • Adding a Toolbox Bitmap

A control designer defines the behavior and UI presentation of a control during design-time. In VS .NET, forms can be created using the Forms Designer. This Forms Designer allows controls, such as buttons, menus, and toolbars, to be drawn on the form rather than being created pragmatically. Each control has an associated designer that defines the behavior of the control during the visual design-time process of building a Windows Forms application.

During design-time, a control's properties can be manipulated using the Property Grid. The control should appear very similar to the runtime look while being designed, with a few exceptions. These exceptions include the handling of a control's Visible property and any designer clues such as the placement grid. The placement grid is the series of dots used for aligning controls during design-time that are not shown at runtime. In general, however, a control's appearance during design-time should give an accurate representation of the control's appearance during runtime.

Note

Certainly, setting the control's Visible property to false during design-time should not make the control invisible. If this were the case, there would be no way to select the control and continue to visually design it.


Designers are an important part of the equation in developing custom controls. By providing a rich design-time experience, application developers can visually build applications using the custom control you've created. The UI presentation is not a designer's sole responsibility; designers must also provide for proper serialization of the code generated for the control, in order for the control to work properly at runtime. The code for the construction of the control, along with the necessary property settings, is serialized within the InitializeComponent method of the form hosting the control. This is the reason for the all-too-familiar comment on the method stating, "This code should not be modified as the designer will OVER WRITE this method when serializing the form's design state."



    .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