kirsan31/winforms-datavisualization

How do I get designer to work

Closed this issue · 3 comments

I want to see at least the chart on a form/Panel

It must work after you correctly reference System.Windows.Forms.DataVisualization.dll (the dll must exists of course). You can test it in DesignerTest project (you need to reference by dll not by project first, due to designer bug).

chartDesigner.mp4

Or if your question was about absent of chart control in control toolbox for fresh (without existing chart) WinForms project? Then...
Here was some discussion about that: dotnet/winforms#7073 (comment)
But the answers not so obvious :(

Currently in my knowledge: a simple (only server side designer) user control (chart is simple in this terms for now) will be visible in controls toolbox in one of this scenarios:

  • Nuget package. Not our case yet :(
  • Control project added to solution.
  • Control in the same project.

In all cases this option must be enabled:
image

Unfortunately if you simple add reference to a user control dll - this control will not appear at the toolbox 😢 We will be able to use designer with already existing charts on the forms, but we won't be able to add new ones. I think this is good issue to rise in WinForms repo...

So, to fix this problem we have plenty of options. Here are two most simple of them:

  • Add ChartWin.csproj to your solution. You may need to restart the solution.
  • Add this class to your project:
    public class MyChart : System.Windows.Forms.DataVisualization.Charting.Chart
    {
    }
    rebuild project. Drug and drop MyChart control to your form and save it. Then if you wish you can replace all YourNamespace.MyChart in Form*.Designer.cs with System.Windows.Forms.DataVisualization.Charting.Chart.

Thanks, works perfect.
image