Wrox Programmer Forums
|
BOOK: Professional Crystal Reports for VS.NET
This is the forum to discuss the Wrox book Professional Crystal Reports for Visual Studio .NET by David McAmis; ISBN: 9780764544033
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Crystal Reports for VS.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 17th, 2006, 03:23 AM
Registered User
 
Join Date: Feb 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default A newbie's simple question

Hi there,

  I added two type of unbound fields (string and number) to a blank report and tried to reference the field's name and change their color. But I received the "invalid report object name" error. Can any expert here tell me what I am missing or what I have done wrong? Thanks in advance!

Code:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using CrystalDecisions.CrystalReports.Engine;

namespace CR_Test{
 public class BlankReportForm : System.Web.UI.Page{
  protected CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer1;

  protected BlankReport bRpt;
 
  private void Page_Load(object sender, System.EventArgs e){
   bRpt = new BlankReport();


   //The following two lines of code work
   bRpt.DataDefinition.FormulaFields["strField"].Text = "\"myStrField\"";
   bRpt.DataDefinition.FormulaFields["numField"].Text = "\"myNumField\"";

   //the following two lines of code throw exception 
   //CrystalDecisions.CrystalReports.Engine.InvalidArgumentException: Invalid report object name.
   Response.Write(bRpt.ReportDefinition.ReportObjects["strField"].Name + "<br>");
   Response.Write(bRpt.ReportDefinition.ReportObjects["numField"].Name + "<br>");

   //the following two lines of code also throw exception 
   //CrystalDecisions.CrystalReports.Engine.InvalidArgumentException: Invalid report object name.
   ((FieldObject)bRpt.ReportDefinition.ReportObjects["strField"]).Color = System.Drawing.Color.Red;
   ((FieldObject)bRpt.ReportDefinition.ReportObjects["numField"]).Color = System.Drawing.Color.Blue;

   CrystalReportViewer1.ReportSource = bRpt;
  }

  #region Web Form Designer generated code
  override protected void OnInit(EventArgs e){
   InitializeComponent();
   base.OnInit(e);
  }

  private void InitializeComponent(){    
   this.Load += new System.EventHandler(this.Page_Load);

  }
  #endregion
 }
}







Similar Threads
Thread Thread Starter Forum Replies Last Post
Very Simple Question YoungLuke C# 2 May 4th, 2007 02:23 AM
Simple Question ironchef Java GUI 0 September 14th, 2006 04:56 PM
Simple Question dpkbahuguna Java Basics 2 May 19th, 2006 12:05 AM
Simple question happyheart_man Pro VB.NET 2002/2003 0 January 14th, 2004 11:38 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.