DashboardLayout for WinForms | ComponentOne
C1.Win.Layout Namespace / C1DashboardLayout Class
Members

In This Topic
    C1DashboardLayout Class
    In This Topic
    The C1DashboardLayout is a layout control that lets you design dynamic screens and dashboards.
    Object Model
    C1DashboardLayout ClassDashboardCollection ClassDashboardItem ClassDashboardOptions ClassDashboardTheme Class
    Syntax
    'Declaration
     
    
    Public Class C1DashboardLayout 
       Inherits System.Windows.Forms.Control
    public class C1DashboardLayout : System.Windows.Forms.Control 
    Remarks

    The C1DashboardLayout class allows you to define the behavior of the DashboardLayout control with the help of following options:

    • Specify which layout type (Flow, Grid or Split) should be used to arrange the child containers/tiles on the C1DashboardLayout with its LayoutType property to present various controls/data.
    • Add or remove child containers with the help of its Items property and can set their Caption and ID.
    • Restore or maximize the child container with the help of Maximize and Restore methods.
    • Customize the appearance of the DashboardLayout, the child containers and their headers with the help of C1DashboardLayout’s Styles property.
    • It exposes Options property which can be used to set additional dashboard options to be used by the layout control, such as limiting the minimum and maximum size to which a child container can be resized, setting the location of tool-icon if Caption property is not defined for the ItemContainer and customizing the context menu strip which is shown on the click of the tool-icon.
    • Access the selected child container with the help of the GetSelectedItem method
    • Save or load the layout properties, such as the order and the bounds of the child containers/tiles to and from an XML file or an XML stream. For this purpose, the C1DashboardLayout class provides SaveLayout and LoadLayout methods.
    Example

    This example instantiates the object of C1DashboardLayout and shows its basic implementation with various options mentioned above.

    private void InitializeDashboardLayout()
    {
         //Initialize the DashboardLayout Control
         C1DashboardLayout c1DashboardLayout1 = new C1.Win.Layout.C1DashboardLayout(); 
         c1DashboardLayout1.Dock = DockStyle.Fill;
         //Setting the type of layout through C1DashboardLayout's LayoutType property.
         c1DashboardLayout1.LayoutType = C1.Win.Layout.LayoutType.Flow;
         //Adding child containers and controls to the DashboardLayout
         c1DashboardLayout1.Items.Add(Guid.NewGuid().ToString(), new List<Control>() { new Button() { Text = "New Button", Location = new Point(10, 10) } });
         c1DashboardLayout1.Items.Add(Guid.NewGuid().ToString(), new List<Control>() { new Label() { Text = "New Label", Location = new Point(10, 10) } });
         //Removing child container from the DashboardLayout
         c1DashboardLayout1.Items.Remove(c1DashboardLayout1.Items[1].Id);
         //Adding header to the child container
         c1DashboardLayout1.SetCaption(c1DashboardLayout1.Items[0].ItemContainer,"First Child Container");
         //Sets the minimum and maximum size to which the child containers can be resized
         c1DashboardLayout1.Options.MinimumItemContainerSize = new System.Drawing.Size(100, 100);
         c1DashboardLayout1.Options.MaximumItemContainerSize = new System.Drawing.Size(500, 500);
         //Maximizes the specified child container
         c1DashboardLayout1.Maximize(c1DashboardLayout1.Items[0]);
         //Restores the maximized child container
         c1DashboardLayout1.Restore();
         //Gets the selected child container
         DashboardItem selectedItem=c1DashboardLayout1.GetSelectedItem();
         //Styling the tool-icon
         c1DashboardLayout1.Styles.ItemContainer.ToolIcon = Properties.Resources.ToolIcon;
         c1DashboardLayout1.Styles.ItemContainer.ToolIconColor = Color.Green;
    
         //Sets the position of the tool-icon to upper left corner of the child containers
         c1DashboardLayout1.Options.ToolIconAppearance = ToolIconAppearance.UpperLeft;
         //Customizes the context menu strip which is shown on the click of the tool-icon
         c1DashboardLayout1.Options.ContextMenuStrip = contextMenuStrip1;
         this.Controls.Add(c1DashboardLayout1);
    }
    private void LoadDashboardLayout()
    {
         //Loads the layout properties from an XML file.
         c1DashboardLayout1.LoadLayout("DashboardLayout.xml");
                
    }
    private void SaveDashboardLayout()
    {
         //Saves the layout properties to an XML file.
         c1DashboardLayout1.SaveLayout("DashboardLayout.xml");
    }
    
    Inheritance Hierarchy

    System.Object
       System.MarshalByRefObject
          System.ComponentModel.Component
             System.Windows.Forms.Control
                C1.Win.Layout.C1DashboardLayout

    See Also