question

Eduardoorozco-4653 avatar image
0 Votes"
Eduardoorozco-4653 asked cooldadtx answered

Chart not compatible with framework 6.0?

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

dotnet-runtimedotnet-entity-framework-coremicrosoft-graph-toolkit
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

cooldadtx avatar image
0 Votes"
cooldadtx answered

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.