Chart tool is greyed out in Visual Studio

2019-02-19 07:35发布

问题:

I'm trying to add a chart to my Visual Studio form but the button is greyed out. I'm using .NET Framework 3.5 and C#. Following instructions online I've downloaded and installed the dll files from this link: http://www.microsoft.com/en-us/download/details.aspx?id=14422 I also added them as references and added the following line at the top of my form file:

using System.Windows.Forms.DataVisualization.Charting;

but the button is still greyed out.

What have I missed?

回答1:

To make the chart control available, you need:

  1. To be using .Net framework 4.0 or higher, OR for .Net framework 3.5 install this: http://www.microsoft.com/en-us/download/details.aspx?id=14422
  2. On the toolbox context menu -> Choose Items... have the Chart control selected. (Sort by name in the Choose Toolbox Items dialog and scroll to Chart. There are two: one for Windows forms, one for Web forms. You need only select what's relevant.)

The chart control appears in the "Data" section of the Toolbox.

You do NOT need to any any "using" clause to the form source file, or any reference in the project references. (The reference is added automatically for you when you add the control.)



回答2:

I too had this issue and could not resolve it for hours.

As posted here: Visual Studio 2010 toolbox controls disabled or inactive

In order to solve it for me I just right-clicked one of the items in the toolbox, and chose "Reset Toolbox"

This resets the entire toolbox, so as mentioned in the answer above, all custom tools are lost and need to be re-imported.



回答3:

Had the same problem.

What I did was to make sure that I was using the same Framework with the chart framework version.

During project creation, by default using .net 3.5. But since the chart is written for Framework 4.0, it will not work with 3.5.

You need to change the solution or project Framework to 4.0 or above by doing this:

  1. On the menu bar of Visual Studio, click <your project name>/Properties.

  2. Change target framework to 4.0 or above.

  3. Save the properties setting.

  4. Rebuild your solution.

After this, you may use that chart component.