Chart for .NET / User's Guide / Layout / Docking Panels

In This Topic
    Docking Panels
    In This Topic
    The NDockPanel class inherits from the NContentPanel class and extends it by adding the Location and DockMode properties. Those two properties allow docking panels to be either attached to a side(s) of their containing panel or aligned relative to a location in the containing panel coordinate system (floating).

    The NChart, NLegend, NLabel and NWatermark panels inherit from the NDockPanel class. This means that these panels support docking which is controlled via the DockMode property accepting values from the PanelDockMode enumeration.

    By default the docking mode for all panels is set to PanelDockMode.None and in this mode the panel position is determined by it's Location and ContentAlignment properties (floating panel).

     Location

    When the DockMode property is set to PanelDockMode.None the panel position is controlled from the Location and ContentAlignment properties. The location property is specified in NPointL format. This means that it is actually a composition of two NLengths each one of them consisting of a Value and Measurement Unit. For more information on Measurement Units please consult the Nevron Presentation Layer User's Guide. The following code will create a label and position it in the middle of the chart canvas:

    C#
    Copy Code
    NLabel label = new NLabel("My Center Label");
    
    label.Location = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage),
    new NLength(50, NRelativeUnit.ParentPercentage));
    label.ContentAlignment = ContentAlignment.MiddleCenter;
    
    chartControl.Panels.Add(label);
    
    Visual Basic
    Copy Code
    Dim label As New NLabel("My Center Label")
    
    label.Location = New NPointL(New NLength(50, NRelativeUnit.ParentPercentage), New NLength(50, NRelativeUnit.ParentPercentage))
    label.ContentAlignment = ContentAlignment.MiddleCenter
    
    chartControl.Panels.Add(label)
    

    The fact that the location property is specified in NPointL format gives you great flexibility when you position panels on the canvas. Suppose you have to position the label ten pixels away from the left top corner of the canvas. In this case the code should look like:

    C#
    Copy Code
    NLabel label = new NLabel("My Left Top Label");
    
    label.Location = new NPointL(new NLength(10, NGraphicsUnit.Pixel),
    new NLength(10, NGraphicsUnit.Pixel));
    label.ContentAlignment = ContentAlignment.BottomRight;
    
    chartControl.Panels.Add(label);
    
    Visual Basic
    Copy Code
    Dim label As New NLabel("My Left Top Label")
    
    label.Location = New NPointL(New NLength(10, NGraphicsUnit.Pixel), New NLength(10, NGraphicsUnit.Pixel))
    label.ContentAlignment = ContentAlignment.BottomRight
    
    chartControl.Panels.Add(label)
    
    All locations are computed relatively to the panel parent.
     DockMode

    To modify the dock mode of the panel you should use the following code:

    C#
    Copy Code
    someDockingPanel.DockMode = PanelDockMode.Fill;
    
    Visual Basic
    Copy Code
    someDockingPanel.DockMode = PanelDockMode.Fill
    

    The following table lists the available dock modes:

    PanelDockMode Description
    Bottom The panels's bottom edge is docked to the bottom of its containing panel. The panel width equals the containing panel width. The panel height is calculated as if the panel is floating.
    Fill All the panel's edges are docked to the all edges of its containing panel and sized appropriately. The panel width and height match the containing panel width and height.
    Left The panel's left edge is docked to the left edge of its containing panel. The panel width is calculated as if the panel is floating. The panel height equals the containing panel height.
    None The panel is not docked. The panel width and height are calculated as if the panel is floating.
    Right The panel's right edge is docked to the right edge of its containing panel. The panel width is calculated as if the panel is floating. The panel height equals the containing panel height.
    Top The panel's top edge is docked to the top of its containing panel. The panel width equals the containing panel width. The panel height is calculated as if the panel is floating.
    See Also