ChartView custom item in a ListView

4 posts, 0 answers
  1. Justin
    Justin avatar
    9 posts
    Member since:
    Oct 2011

    Posted 06 Mar 2014 Link to this post

    Hello,

    I am trying to create a ListView that contains a custom visual item containing multiple ChartViews.   What I am trying to achieve is a list, with some text for each item on the left and multiple pie charts horizontally across the item.  I have looked at the documentation for creating custom items in a ListView and taken basically the same approach.  I create a StackLayoutPanel in CreateChildItems in my SimpleListViewVisualItem derived class.  I add a LightVisualElement to the layout which will contain some text.  Then I try to add RadChartElements to the stack.  The problem is I cannot figure out the correct way to create the RadChartElement for this scenario.   I have tried many variations, but none seem to work. 

     I have tried to declare RadChartView's as members in the VisualItem class, create them in them in CreateChildItems and add them with a call like layout.Children.Add(myChartView.ChartElement).   Then in SynchronizeProperties, I go ahead and blow away the series for the chart and recreate it with the correct data for the item.  This almost works, except that only the first item in my list will ever display correctly. 

    I have tried to declare RadChartElement's as members of the VisualItem class, but then I cannot figure out how to set the series for the chart in SynchronizeProperties

    I have even tried creating the RadChartView in CreateChildItems, then in SynchronizeProperties, I just recreate the RadChartView and point the children of the layout to the newly created chart.ChartElement.

    I have tried just recreating the entire layout in SynchronizeProperties.

    ...and many more combinations.

    The best I could do with any of my attempts did correctly display the *first item*, with text on the left and four pie charts with correct data to the right, but *only the first item*.  In all the other items, the chart elements appear blank.

    Is this impossible in the current version of the controls for Winforms, or am I missing something?

    Best regards,
    Justin

  2. George
    Admin
    George avatar
    500 posts

    Posted 11 Mar 2014 Link to this post

    Hello Justin,

    Thank you for contacting us.

    It is possible to integrate RadChartView into RadListViewItems. I have created a small sample where this is achieved. Basically you need to get the Series from the data item, clone them (due to the virtualization of the visual items) and add them to the chart element.

    Below you can find a sample project with these features implemented, feel free to implement any further changes.

    Do not hesitate to write back, should you have further questions.

    Regards,
    George
    Telerik

    DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Justin
    Justin avatar
    9 posts
    Member since:
    Oct 2011

    Posted 11 Mar 2014 Link to this post

    Hello and thank you very much for your reply.  I have since discovered an error in my code that caused the unwanted behavior.  I have, however, noticed some somewhat odd behavior with the formatting of labels and colors during my attempts to get this working that I still don't fully understand.  Thank you for posting the example program.  I will take a look to see if I am using the best approach.  I'm sure others who would like to have ChartViews in their ListView will also find it helpful.

    Thanks again,
    Justin
  5. George
    Admin
    George avatar
    500 posts

    Posted 14 Mar 2014 Link to this post

    Hi Justin,

    I am glad that this solution has worked well for your case.

    Let us know if you have any other questions in future.

    Regards,
    George
    Telerik
     

    DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

     
Back to Top