Chart not compatible with framework 6.0?

Eduardo orozco 1 Reputation point
2022-05-06T14:56:10.337+00:00

Hi,

I'm developing a system in visual studio 2022, the project was created as Windows Forms App with framework 6.0 in c# (not Windows Forms App . NET Framework), currently I need to add a chart item, but, this item does not appear in the toolbox, I have tried to add the chart item doing right click in the toolbox --> selecting "choose Items" --> searching "chart" in the list and selecting it --> finally click on the "OK" button.

surfing on internet, I found that the framework 6.0 is not compatible with chart, so now, I wonder what I can do to make a plot in my project?

I really appreciate it if someone can help me

Developer technologies .NET Entity Framework Core
Developer technologies .NET .NET Runtime
Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Michael Taylor 60,161 Reputation points
    2022-05-06T16:06:50.793+00:00

    You don't really need the chart in the toolbox to use it. When you drag and drop the control from the toolbox onto your form then all it does is generate a private field of the chart type and then create an instance of it in the *.designer.cs file and sets the properties. If you look at the contents of that file you can see the pattern it uses. So

    1) Create a private field for the Chart.
    2) In InitializeComponent method create an instance of it
    3) At a minimum set the Name property to match the field name and set the initial size.
    4) If it implements ISupportInitialize(??) then call BeginInit and EndInit methods like it does for the other controls.
    5) Add the control to the form's Controls property like it does for the other controls.

    You can now switch back to the designer and see the control and set properties normally. However, none of the custom chart editors will be available. Therefore anything you cannot directly set in the Properties window will have to be set by hand.

    The recommended alternative is to create a dummy Winforms .NET Framework app. Add a link to your existing form in the other project. Then use the .NET Framework designer to edit the control. This is the hack approach for controls that don't support the .NET Core designer.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.