This is a migrated thread and some comments may be shown as answers.

Layout Control set many Charts

3 Answers 93 Views
LayoutControl
This is a migrated thread and some comments may be shown as answers.
Patricia
Top achievements
Rank 1
Patricia asked on 30 Apr 2020, 08:11 PM

 Hi everybody !

   I Have this xml that load the radLayout Control?

   <RadLayoutControl TabIndex="0">
  <Items>
    <Telerik.WinControls.UI.LayoutControlSeparatorItem Bounds="0, 0, 910, 4" Name="layoutControlSeparatorItem3" />
    <Telerik.WinControls.UI.LayoutControlItem AssociatedControlName="" DrawText="False" Text="" Bounds="0, 376, 455, 251" />
    <Telerik.WinControls.UI.LayoutControlItem AssociatedControlName="" DrawText="False" Text="" Bounds="455, 376, 455, 251" />
    <Telerik.WinControls.UI.LayoutControlItem AssociatedControlName="" DrawText="False" Text="" Bounds="0, 198, 455, 178" />
    <Telerik.WinControls.UI.LayoutControlItem AssociatedControlName="" DrawText="False" Text="" Bounds="455, 198, 455, 178" />
    <Telerik.WinControls.UI.LayoutControlItem AssociatedControlName="" DrawText="False" Text="" Bounds="0, 4, 455, 194" />
    <Telerik.WinControls.UI.LayoutControlItem AssociatedControlName="" DrawText="False" Text="" Bounds="455, 4, 455, 194" />
  </Items>
</RadLayoutControl>

  When load the layout from "this.radLayoutControl2.LoadLayout(pathTheXml);" My ideia is set in each LayoutControlItem the Chart. I try this:

    var itens = this.radLayoutControl2.Items.OfType<LayoutControlItem>().ToList();
            var layoutSeparator = this.radLayoutControl2.Items.OfType<LayoutControlSeparatorItem>().FirstOrDefault();

            foreach (var newTeamMemberItem in itens)
            {
                RadChartView radChartView = new RadChartView();
                radChartView.Title = "AAAAAA";
                radChartView.Name = "radChartView" + index;
                radChartView.ThemeName = this.radLayoutControl1.ThemeName;
                setChart(chartModelArea, radChartView, EnumTipoGrafico.Barra);

                newTeamMemberItem.Name = "nameStart";
                newTeamMemberItem.AssociatedControl = radChartView;
                newTeamMemberItem.DrawText = true;
                newTeamMemberItem.MaxSize = newTeamMemberItem.MaxSize;
                newTeamMemberItem.MinSize = newTeamMemberItem.MinSize;
                newTeamMemberItem.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
                newTeamMemberItem.TextFixedSize = 26;
                newTeamMemberItem.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
                newTeamMemberItem.TextPosition = Telerik.WinControls.UI.LayoutItemTextPosition.Top;
                newTeamMemberItem.TextSizeMode = Telerik.WinControls.UI.LayoutItemTextSizeMode.Fixed;

                if (layoutSeparator != null)
                this.radLayoutControl2.AddItem(newTeamMemberItem, layoutSeparator, LayoutControlDropPosition.Bottom);
                else
                    this.radLayoutControl2.AddItem(newTeamMemberItem, newTeamMemberItem, LayoutControlDropPosition.Bottom);
            }

 

    But this doesn't work. Can you help please. Thanks

 

   

 

3 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 05 May 2020, 09:02 AM

Hello, Marco,

Following the provided information, I have prepared a sample project. Please refer to the attached sample project for your reference. 

I have removed the separators in order to size the charts in a more convenient way. The below screenshot illustrates the obtained result on my end:

Please give the sample project a try and see how it works on your end.

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Patricia
Top achievements
Rank 1
answered on 08 May 2020, 10:41 PM

 Hi Dess, this works very thank you !

           Do you create ItemLayoutControl in runtime ? If yes can you show me ? 

0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 13 May 2020, 08:53 AM

 

Hello, Marco, 

Please refer to the attached sample project from my previous reply. 

The only change that I made in the code snippet was to comment the last code lines with adding LayoutControlSeparatorItems and just leave the load layout functionality to do the rest:   
        public RadForm1()
        {
            InitializeComponent();
            this.radLayoutControl1.LoadLayout(@"..\..\layout.xml"); 
            
            var itens = this.radLayoutControl1.Items.OfType<LayoutControlItem>().ToList();
            var layoutSeparator = this.radLayoutControl1.Items.OfType<LayoutControlSeparatorItem>().FirstOrDefault();
            int index = 0;
            foreach (var newTeamMemberItem in itens)
            {
                index++;
                RadChartView radChartView = new RadChartView();
                radChartView.Title = "AAAAAA";
                radChartView.Name = "radChartView" + index;
                radChartView.ThemeName = this.radLayoutControl1.ThemeName;
                SetChart( radChartView);

                newTeamMemberItem.Name = "nameStart";
                newTeamMemberItem.AssociatedControl = radChartView;
                newTeamMemberItem.DrawText = true;
                newTeamMemberItem.MaxSize = newTeamMemberItem.MaxSize;
                newTeamMemberItem.MinSize = newTeamMemberItem.MinSize;
                newTeamMemberItem.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
                newTeamMemberItem.TextFixedSize = 26;
                newTeamMemberItem.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
                newTeamMemberItem.TextPosition = Telerik.WinControls.UI.LayoutItemTextPosition.Top;
                newTeamMemberItem.TextSizeMode = Telerik.WinControls.UI.LayoutItemTextSizeMode.Fixed;

                //if (layoutSeparator != null)
                //    this.radLayoutControl1.AddItem(newTeamMemberItem, layoutSeparator, LayoutControlDropPosition.Bottom);
                //else
                //    this.radLayoutControl1.AddItem(newTeamMemberItem, newTeamMemberItem, LayoutControlDropPosition.Bottom);
            }
        }
Should you have further questions please let me know.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
LayoutControl
Asked by
Patricia
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Patricia
Top achievements
Rank 1
Share this question
or