Assisted Solutions - Active Org-Chart - Demos
Active Org-Chart 1.0 Demos
© 2006-2010 Info Mason. All rights reserved

Return To Menu Custom data binding Next Demo

ABOUT THIS DEMO:
You may use your own code to bind complex data to the chart. Simply build your hierarchy of Entities, and set the chart's RootEntity property. In this demo, this approach is used, and a different color is applied to each level in the hierarchy. View the code to see how this is accomplished.


Demo Area

   

    private IDrawnEntity ToEntity(DataTable dt, DataRow dr, IDrawnEntity parent, int level)
    {
        DefaultDrawnEntity newEntity = new DefaultDrawnEntity((string)dr["FullName"], orgDemo);
        newEntity.Identity = ((int)dr["PersonID"]).ToString();

        if (parent != null) parent.AddChild(newEntity);

        DataRow[] children = dt.Select("ParentPersonID = " + dr["PersonID"].ToString());
        foreach (DataRow child in children)
        {
            ToEntity(dt, child, newEntity, level + 1);
        }

        newEntity.FillBrush = new LinearGradientBrush(
            new Rectangle(0, 0, newEntity.BoxSize.Width, newEntity.BoxSize.Height),
            Color.White,
            Color.FromArgb(200, colors[level]),
            LinearGradientMode.Vertical);

        return newEntity;
    }