namespace WindowsFormsApplication1
{
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;
    using Telerik.Reporting;
    using Telerik.Reporting.Drawing;
    using System.Collections.Generic;
    using System.Data.SqlClient;

    /// <summary>
    /// Summary description for Report3.
    /// </summary>
    public partial class OrgChart : Telerik.Reporting.Report
    {
        public OrgChart()
        {
            InitializeComponent();

            // decrease the detail section height in case the subreport is hiden
            this.detail.Height = this.detail.Height - this.ManagedEmployees.Height;
        }

        public static ReportSource CreateReportInstance(Telerik.Reporting.Processing.SubReport item)
        {
            // get the data to wich the subreport item is bound
            var subReportItemData = item.DataObject;
            var managedEmployees = (List<Employee>)subReportItemData["ManagedEmployees"];

            if (null != managedEmployees)
            {
                // create new instance of the same report
                var r = new OrgChart();

                // and bind it to the managed employees
                r.DataSource = managedEmployees;

                return new InstanceReportSource { ReportDocument = r };
            }

            return null;
        }
    }
}