473,396 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Build error object reference??

I have been getting the following error fro an event in an
rpx.cs file. The error is as follows: An object reference
is required for the nonstatic field, method, or
property 'DataDynamics.ActiveReports.ActiveReport.Sections'
Can someone point me in the right direction in terms of
where I am going wrong.

private void Detail_Format(object sender, System.EventArgs
eArgs)
{
if(((CheckBox)Test.Sections["Detail"].Controls
["chcomplaint"]).DataField == "1")
{
((CheckBox)Test.Sections["Detail"].Controls
["chcomplaint"]).Checked = true;
}
else
{
((CheckBox)Test.Sections["Detail"].Controls
["chcomplaint"]).Checked = false;
}

}
Nov 16 '05 #1
6 1535
Laura Carr <an*******@discussions.microsoft.com> wrote:
I have been getting the following error fro an event in an
rpx.cs file. The error is as follows: An object reference
is required for the nonstatic field, method, or
property 'DataDynamics.ActiveReports.ActiveReport.Sections'
Can someone point me in the right direction in terms of
where I am going wrong.

private void Detail_Format(object sender, System.EventArgs
eArgs)
{
if(((CheckBox)Test.Sections["Detail"].Controls
["chcomplaint"]).DataField == "1")
{
((CheckBox)Test.Sections["Detail"].Controls
["chcomplaint"]).Checked = true;
}
else
{
((CheckBox)Test.Sections["Detail"].Controls
["chcomplaint"]).Checked = false;
}

}


It's not entirely clear - what's "Test" in this case?

Btw, your code could be made a lot cleaner by separating things out:

CheckBox cb =(CheckBox)Test.Sections["Detail"].Controls["chcomplaint"];

if (cb.DataField=="1")
{
cb.Checked = true;
}
else
{
cb.Checked = false;
}

The if/else block could then be changed to:

cb.Checked = (cb.DataField=="1");

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
Test is the name of the Report file (Test.rpx). I did
what you said and my code now looks like this below.
However I am now getting this build error: An object
reference is required for the nonstatic field, method, or
property 'DataDynamics.ActiveReports.ActiveReport.Sections'
Have you any Idelas what I've done wrong??

CheckBox cb = (CheckBox)Test.Sections["Detail"].Controls
["chcomplaint"];
if (cb.DataField == "1")
{
cb.Checked = true;
}
else
{
cb.Checked = false;
}

It's not entirely clear - what's "Test" in this case?

Btw, your code could be made a lot cleaner by separating things out:
CheckBox cb =(CheckBox)Test.Sections["Detail"].Controls ["chcomplaint"];
if (cb.DataField=="1")
{
cb.Checked = true;
}
else
{
cb.Checked = false;
}

The if/else block could then be changed to:

cb.Checked = (cb.DataField=="1");

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
.

Nov 16 '05 #3
Laura Carr <an*******@discussions.microsoft.com> wrote:
Test is the name of the Report file (Test.rpx).


Ah. In that case, the problem is that you're trying to use an instance
property as if it were static. You'll need a reference to an instance
of the Test class.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #4
Im sorry im really new to coding and im not 100% sure what
you mean here. How do I create a reference to an instance
of a Test class and where abouts should I do this. Thanks
so much for your help.
-----Original Message-----
Laura Carr <an*******@discussions.microsoft.com> wrote:
Test is the name of the Report file (Test.rpx).
Ah. In that case, the problem is that you're trying to

use an instanceproperty as if it were static. You'll need a reference to an instanceof the Test class.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
.

Nov 16 '05 #5
Laura Carr <an*******@discussions.microsoft.com> wrote:
Im sorry im really new to coding and im not 100% sure what
you mean here. How do I create a reference to an instance
of a Test class and where abouts should I do this. Thanks
so much for your help.


I don't know about reports, to be honest, which is a problem here -
chances are there's already an instance of Test somewhere, but without
knowing more about reports I can't really tell you how to find it.

I would *strongly* suggest that you start from scratch and learn "plain
C#" first, then start learning about reports when you're comfortable
with C# itself. That way you'll find a lot of the concepts a lot less
daunting, and will be able to solve problems like this easily.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #6
Hi Laura,

While I have never worked with ActiveReports just with CR I assume they
follow the same way of building them. I tell you this cause the explanatio
below is based on CR no on ActiveReports.

CR create a class named like the report you create, if you create a report
named Report1 you will get two files:
Report1.rpt which contains the data needed by the designer and I assume the
report itself, and other named Report1.cs this is the code used in your
program, there you have a Report1 class that derived from Report which is
the abstract base class.

After all this explanation what I think is happening is that you are not
creating a new instance of the report, just using the name of the report
which is a type ( class )
You have to create an instance first:

Report test = new Report1();

Again, remember that the above is valid for CR but I can bet that it's what
you are seeing

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Laura Carr" <an*******@discussions.microsoft.com> wrote in message
news:5b****************************@phx.gbl...
Im sorry im really new to coding and im not 100% sure what
you mean here. How do I create a reference to an instance
of a Test class and where abouts should I do this. Thanks
so much for your help.
-----Original Message-----
Laura Carr <an*******@discussions.microsoft.com> wrote:
Test is the name of the Report file (Test.rpx).


Ah. In that case, the problem is that you're trying to

use an instance
property as if it were static. You'll need a reference to

an instance
of the Test class.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
.

Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Phil Powell | last post by:
Consider this: class ActionHandler { ...
2
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two...
2
by: Good Enchiladas | last post by:
While building on a class library for an VB.NET object model, I get something similar to the above error message, but not with C#. The steps to recreate the problem are as follows: 1. Build a...
10
by: Douglas Buchanan | last post by:
I am using the following code instead of a very lengthly select case statement. (I have a lot of lookup tables in a settings form that are selected from a ListBox. The data adapters are given a...
5
by: JCauble | last post by:
1. We have a web project that has a support dll that uses the following command: HttpContext.Current.Application.ToString(); 2. In our environment we must use a build process that runs from the...
4
by: Vish | last post by:
Hi all, I am having a build error in one of the overloaded functions in my class. The function takes either a string as a parameter or a type referenced in another dll as a parameter. My class...
0
by: pdsluk | last post by:
Hi I have an application which when complied with vb.net 2003 will give one Build Error showing the in task list. The build window reports no errors and rebuild was all sucessful. The error is ...
1
by: AlexZh | last post by:
Hi, I'd like to stop command line build by one project build failed. To do that I've created simple AddIn (see code below), that works fine for IDE and does not work for command line. In the AddIn...
3
by: NickP | last post by:
Hi there, Today I try to compile an application of mine and I am getting a whole list of bizaar errors.... ------------------------------------------------ Error 1 The...
3
by: Hugh Oxford | last post by:
I want to build a string to reference an object. I can reference is manually thus: print_r($this->struct->parts->parts); but if I build a string... $string = "->parts->parts"
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.