重命名Telerik报告图例项

时间:2012-04-18 05:36:49

标签: c# telerik reporting legend

我在Visual Studio中使用Telerik Reporting 2010工作。我试图在饼图中重命名图例的标签。我认为我的问题在于代码,但我的知识有限,所以我看不出什么是错的。任何人都可以帮我找到什么错误?我得到的错误在底部。

namespace Reports
{
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using Telerik.Reporting;
using Telerik.Reporting.Drawing;


/// <summary>
/// Summary description for DeliveryStatus___Client.
/// </summary>
public partial class DeliveryStatus___Client : Telerik.Reporting.Report
{
    public DeliveryStatus___Client()
    {
        //
        // Required for telerik Reporting designer support
        //
        InitializeComponent();}


        //
        // TODO: Add any constructor code after InitializeComponent call
        //
    private void chart1_ItemDataBinding(object sender, EventArgs e)
{
        var procChart = ((Telerik.Reporting.Processing.Chart)sender);


        Telerik.Reporting.Charting.LabelItem labelItem1 = new       Telerik.Reporting.Charting.LabelItem();
        Telerik.Reporting.Charting.LabelItem labelItem2 = new   Telerik.Reporting.Charting.LabelItem();

            labelItem1.Marker.Visible = true;
            labelItem1.Name = "LegendItem1";
            labelItem1.TextBlock.Text = procChart.Report.Parameters["Due Beyond"].Value.ToString;
            labelItem2.Marker.Visible = true;
            labelItem2.Name = "LegendItem2";
            labelItem2.TextBlock.Text = procChart.Report.Parameters["Due Monday"].Value.ToString;
            this.chart1.Legend.Items.AddRange(new Telerik.Reporting.Charting.LabelItem[] {
            labelItem1,
            labelItem2});
        this.chart1.Legend.Items.AddRange(new Telerik.Reporting.Charting.LabelItem[] {labelItem1,});
}



     Error  2   Cannot implicitly convert type 'object' to 'string'. An explicit      conversion exists (are you missing a cast?)   C:\Users\wondergoat77\Documents\VS -     Projects\Reports\Reports\DeliveryStatus - Client.cs    34  45  
     Error  3   Type or namespace definition, or end-of-file expected       C:\Users\wondergoat77\Documents\VS - Projects\\Reports\DeliveryStatus - Client.cs   52      1   
      Error 4   Cannot convert method group 'ToString' to non-delegate type     'string'. Did you intend to invoke the method?  C:\Users\wondergoat77\Documents\VS -     Projects\Reports\Reports\DeliveryStatus - Client.cs    34  45  
      Error 5   Cannot convert method group 'ToString' to non-delegate type     'string'. Did you intend to invoke the method?  C:\Users\wondergoat77\Documents\VS -     Projects\Reports\Reports\DeliveryStatus - Client.cs    37  45  










     }
         }
     }

1 个答案:

答案 0 :(得分:1)

你忘了ToString是一个方法,所以你必须调用它(添加括号):

labelItem1.TextBlock.Text = procChart.Report.Parameters["Due Beyond"].Value.ToString();//here
labelItem2.TextBlock.Text = procChart.Report.Parameters["DueMonday"].Value.ToString();//here