类型或命名空间“系列集合”无法找到 [英] The type or namespace "series collection" could not be found

查看:96
本文介绍了类型或命名空间“系列集合”无法找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi
需要SeriesCollection的命名空间我的代码中找不到图表中的点数



我尝试了什么:



< pre>使用System; 
使用 System.Collections.Generic;
使用 System.Linq;
使用 System.Web;
使用 System.Web.UI;
使用 System.Web.UI.WebControls;
使用 System.Drawing;
使用 System.Drawing.Drawing2D;

命名空间 dotnetpro
{
public partial class sample1:System.Web.UI.Page
{
protected void Page_Load( object sender,EventArgs e)
{
Chart.TitleBox.Label.Text = 学生进度;
Chart.Width = 750 ;
Chart.Height = 550 ;
SeriesCollection mySC = Calculate();
Chart.XAxis.Label.Text = 标记;
Chart.YAxis.Label.Text = No of Students;
Chart.SeriesCollection.Add(Calculate());
Chart.DefaultSeries.DefaultElement.URL = JavaScript:myAlert(\'点击元素%名称in series%SeriesName \');
Chart.TitleBox.Position = TitleBoxPosition.Full;
Chart.TitleBox.Label.Font = new 字体( TimesRoman 10 ,FontStyle.Bold | FontStyle.Italic);
Chart.TitleBox.Label.Alignment = StringAlignment.Center;
Chart.TitleBox.Label.Color = Color.DarkBlue;
Chart.TitleBox.Background.Color = Color.FromArgb( 225 122 212 );
Chart.TitleBox.Padding = 7 ;
Chart.LegendBox.DefaultEntry.LabelStyle.Font = new 字体( Arial 10 ,FontStyle.Italic);
Chart.LegendBox.Line.Color = Color.FromArgb( 56 66 177 );
Chart.LegendBox.Line.Width = 2 ;
Chart.LegendBox.Background = new 背景(Color.FromArgb( 165 174 255 ),Color.FromArgb( 233 235 240 ), 45 );
Chart.LegendBox.Orientation = dotnetCHARTING.Orientation.Bottom;
}
SeriesCollection Calculate()
{
SeriesCollection SC = new SeriesCollection();
随机myR = 随机( 1 );
for int a = 0 ; < 4 ; a ++)
{
Series s = new Series();
s.Name = Series + a.ToString();
for int b = 0 ; b < 1 ; b ++)
{
元素e = new Element();
e.Name = 元素 + b.ToString();
e.YValue = myR.Next( 50 );
s.Elements.Add(e);
}

SC.Add(s);
}
SC [ 0 ]。Element.Color = Color.FromArgb( 49 255 49 );
SC [ 0 ]。元素[ 0 ]。Name = 英文;
SC [ 0 ]。LegendEntry.Value = 13;
SC [ 0 ] .LegendEntry.Name = 10-15之间;

SC [ 1 ]。Element.Color = Color.FromArgb( 255 255 0 );
SC [ 1 ]。元素[ 0 ]。Name = 数学;
SC [ 1 ]。LegendEntry.Value = 32;
SC [ 1 ]。LegendEntry.Name = 10-40之间;

SC [ 2 ]。Element.Color = Color.FromArgb( 255 99 49 );
SC [ 2 ]。元素[ 0 ]。Name = 科学;
SC [ 2 ]。LegendEntry.Value = 6;
SC [ 2 ]。LegendEntry.Name = 0-10之间;

SC [ 3 ]。Element.Color = Color.FromArgb( 0 156 255 );
SC [ 3 ]。元素[ 0 ]。Name = 计算机;
SC [ 3 ]。LegendEntry.Value = 18;
SC [ 3 ]。LegendEntry.Name = 15-30之间;
return SC;
}


}
}

解决方案

听起来像你缺少命名空间引用。这里: SeriesCollection Class(System。 Windows.Forms.DataVisualization.Charting) [ ^ ]



解析命名空间的快速提示(和其他整洁的东西):



在VS2015(和VS2013?)中,使用快捷键CTRL +将光标放在带有波浪形红线的行中的任何位置。 (CTRL键+'。'(点)键)或右键单击并选择快速操作和重构...,如果链接了正确的DLL,IntelliSense应该能够快速添加正确的使用{命名空间};参考

Hi Need Namespaces for SeriesCollection And points in chart are not found in my code

What I have tried:

<pre>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace dotnetpro
{
    public partial class sample1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Chart.TitleBox.Label.Text = "Student Progress";
            Chart.Width = 750;
            Chart.Height = 550;
            SeriesCollection mySC = Calculate();
            Chart.XAxis.Label.Text = "Marks";
            Chart.YAxis.Label.Text = "No of Students";
            Chart.SeriesCollection.Add(Calculate());
            Chart.DefaultSeries.DefaultElement.URL = "JavaScript: myAlert(\'Clicked on element %Name in series %SeriesName \')";
            Chart.TitleBox.Position = TitleBoxPosition.Full;
            Chart.TitleBox.Label.Font = new Font("TimesRoman", 10, FontStyle.Bold | FontStyle.Italic);
            Chart.TitleBox.Label.Alignment = StringAlignment.Center;
            Chart.TitleBox.Label.Color = Color.DarkBlue;
            Chart.TitleBox.Background.Color = Color.FromArgb(225, 122, 212);
            Chart.TitleBox.Padding = 7;
            Chart.LegendBox.DefaultEntry.LabelStyle.Font = new Font("Arial", 10, FontStyle.Italic);
            Chart.LegendBox.Line.Color = Color.FromArgb(56, 66, 177);
            Chart.LegendBox.Line.Width = 2;
            Chart.LegendBox.Background = new Background(Color.FromArgb(165, 174, 255), Color.FromArgb(233, 235, 240), 45);
            Chart.LegendBox.Orientation = dotnetCHARTING.Orientation.Bottom;
        }
       SeriesCollection Calculate()
        {
            SeriesCollection SC = new SeriesCollection();
            Random myR = new Random(1);
            for (int a = 0; a < 4; a++)
            {
                Series s = new Series();
                s.Name = "Series " + a.ToString();
                for (int b = 0; b < 1; b++)
                {
                    Element e = new Element();
                    e.Name = "Element " + b.ToString();
                    e.YValue = myR.Next(50);
                    s.Elements.Add(e);
                }

                SC.Add(s);
            }
            SC[0].Element.Color = Color.FromArgb(49, 255, 49);
            SC[0].Elements[0].Name = "English";
            SC[0].LegendEntry.Value = "13";
            SC[0].LegendEntry.Name = "Between 10-15";

            SC[1].Element.Color = Color.FromArgb(255, 255, 0);
            SC[1].Elements[0].Name = "Maths";
            SC[1].LegendEntry.Value = "32";
            SC[1].LegendEntry.Name = "Between 10-40";

            SC[2].Element.Color = Color.FromArgb(255, 99, 49);
            SC[2].Elements[0].Name = "Science";
            SC[2].LegendEntry.Value = "6";
            SC[2].LegendEntry.Name = "Between 0-10";

            SC[3].Element.Color = Color.FromArgb(0, 156, 255);
            SC[3].Elements[0].Name = "Computer";
            SC[3].LegendEntry.Value = "18";
            SC[3].LegendEntry.Name = "Between 15-30";
            return SC;
        }


    }
}

解决方案

Sounds like you are missing a namespace reference. Here: SeriesCollection Class (System.Windows.Forms.DataVisualization.Charting)[^]

A quick tip for resolving namespaces (and other neat stuff):

In VS2015 (and VS2013?), put the cursor anywhere in the line with the squiggly red line, using shortcut CTRL+. (CTRL key + '.' (Dot) key) or right-click and select "Quick Actions and Refactorings...", if the correct DLL is linked in, the IntelliSense should give you the ability to quickly add the correct Using {namespace}; reference.


这篇关于类型或命名空间“系列集合”无法找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆