473,545 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

referencing a class member from another file

I need to call(reference) class member
"PrintDestinati on.PrintDestina tionPrinter" from another file. How do I
do it, I tried
"ReportRenderer .PrintDestinati on.PrintDestina tionPrinter" but it
doesn't work. Please help!

here is my class:

*************** *************** ***********

using System;
using CrystalDecision s.CrystalReport s.Engine;
using CrystalDecision s.Shared;
using System.Data;
using ABELSoft.Report ing.User.Facade ;

namespace ABELSoft.Report ing.User.Facade
{
/// <summary>
/// Summary description for ReportRenderer.
/// </summary>
public class ReportRenderer
{
private CrystalDecision s.CrystalReport s.Engine.Report Document
m_ReportDocumen t;
private string m_sReportName;
private PrintDestinatio n m_PrintDestinat ion;
private string m_sDestinationN ame;
private DataSet m_ReportData;

public void RenderReport()
{
switch( m_PrintDestinat ion )
{
case PrintDestinatio n.PrintDestinat ionScreen:
{
ReportPreviewFa c Preview = new ReportPreviewFa c();
Preview.ReportS ource = m_ReportDocumen t;
Preview.ShowDia log();
break;
}
case PrintDestinatio n.PrintDestinat ionPrinter:
{
m_ReportDocumen t.PrintToPrinte r( 1, false, 0, 0 );
break;
}
case PrintDestinatio n.PrintDestinat ionFile:
{
m_ReportDocumen t.Export();
break;
}
}
}

public enum PrintDestinatio n
{
PrintDestinatio nPrinter,
PrintDestinatio nScreen,
PrintDestinatio nFile
}
#endregion public routines
}
}

Nov 17 '05 #1
1 3540
There are two ways you can do this.

(1) Compile both source files into the same binary output file.

or

(2) Reference the binary file that contains the code you need to use when
building.

Note that both of these require you to do something to the input for the
compiler.

If you are using Visual Studio .NET, here's how it will look:

(1) Make sure the two source files are in the same project. That is all.

(2) Make sure the calling project has a reference to the code being called.
Use the 'Add References' feature. In Solution Explorer, right-click on the
References item for the project that's going to call the function and select
Add References. Add a reference to the component that contains the code you
wish to call. If the component is a different project in the same solution,
add it as a 'Project' reference. Otherwise, Browse... for the DLL.
If you are using the compiler from the command line, here's how it will
look:

(1) csc SourceFile1.cs SourceFile2.cs

or

(2) csc /r:ExternalCompo nent.dll SourceFile1.cs

That "/r" switch is what a 'reference' in VS.NET means. It says "The code
I'm compiling now makes use of classes defined in this external DLL here".

Regardless of which of these two techniques you use, the source code will
look the same. You can either use the fully qualified name, e.g.
ABELSoft.Report ing.User.Facade .ReportRenderer .PrintDestinati on.PrintDestina tionPrinter,
or you can add a 'using' statement to the top of the file:

using ABELSoft.Report ing.User.Facade ;

and then just refer to it as
ReportRenderer. PrintDestinatio n.PrintDestinat ionPrint.

Note that the 'using' statement does not render the steps mentioned earlier
optional. You still need to do either (1) or (2). The 'using' statement is
*never* interpreted by the C# compiler as an instruction to go and look for
some external file. It simply tells it that you plan not to bother using
the full namespace every time.

By the way, in C#, it's not normal to do this:

public enum PrintDestinatio n
{
PrintDestinatio nPrinter,
PrintDestinatio nScreen,
PrintDestinatio nFile
}

This looks like something a C++ developer would do. In C# we normally do
this:

public enum PrintDestinatio n
{
Printer,
Screen,
File
}

That would be a bad idea in C++ of course because in C++, enumeration entry
names are scoped by namespace. But in C#, you never ever see the name of
an enumeration entry used in isolation. It is *required* to be referred to
via its containing enum name. So it would always be
PrintDestinatio n.Printer, etc. Given this fact, putting the enum name in
the enum member is always redundant.
--
Ian Griffiths - http://www.interact-sw.co.uk/iangblog/

<Dj******@ABELS oft.com> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.com.. .
I need to call(reference) class member
"PrintDestinati on.PrintDestina tionPrinter" from another file. How do I
do it, I tried
"ReportRenderer .PrintDestinati on.PrintDestina tionPrinter" but it
doesn't work. Please help!

here is my class:

*************** *************** ***********

using System;
using CrystalDecision s.CrystalReport s.Engine;
using CrystalDecision s.Shared;
using System.Data;
using ABELSoft.Report ing.User.Facade ;

namespace ABELSoft.Report ing.User.Facade
{
/// <summary>
/// Summary description for ReportRenderer.
/// </summary>
public class ReportRenderer
{
private CrystalDecision s.CrystalReport s.Engine.Report Document
m_ReportDocumen t;
private string m_sReportName;
private PrintDestinatio n m_PrintDestinat ion;
private string m_sDestinationN ame;
private DataSet m_ReportData;

public void RenderReport()
{
switch( m_PrintDestinat ion )
{
case PrintDestinatio n.PrintDestinat ionScreen:
{
ReportPreviewFa c Preview = new ReportPreviewFa c();
Preview.ReportS ource = m_ReportDocumen t;
Preview.ShowDia log();
break;
}
case PrintDestinatio n.PrintDestinat ionPrinter:
{
m_ReportDocumen t.PrintToPrinte r( 1, false, 0, 0 );
break;
}
case PrintDestinatio n.PrintDestinat ionFile:
{
m_ReportDocumen t.Export();
break;
}
}
}

public enum PrintDestinatio n
{
PrintDestinatio nPrinter,
PrintDestinatio nScreen,
PrintDestinatio nFile
}
#endregion public routines
}
}

Nov 17 '05 #2

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

Similar topics

3
3586
by: DanielBradley | last post by:
Hello all, I have recently been porting code from Linux to cygwin and came across a problem with static const class members (discussed below). I am seeking to determine whether I am programming non-standard C++ or if the problem lies elsewhere. To summarize static const class members are not being accessed properly when accessed from a...
13
2711
by: jt | last post by:
Being a newbie in C++ and comming from C, I can't find information on how to access a class member function outside its class. Below is a snippet of the class and its member function: look at "AddCallPages" ============================================================= class CPsnstatuspttView : public CFormView { protected: // create from...
11
2790
by: Milind | last post by:
Hi, I was trying to implement a composition relation, somthing of the following type: class A { public: class B {
13
1833
by: Duron | last post by:
I created a new folder using VS.NET 2003. Then I created a new web form under that folder, say, \Member\Default.aspx. However, even if I didn't do anything to that page, a run-time error appears when I try to run it -- Can not load class MySite._Default. I am using VB to write codes. Does anyone have any idea why this problem happens?...
6
2467
by: Mikey_Doc | last post by:
Hi We are running cms 2002, Framework 1.0 with Visual studio 2002. We have just upgraded to Framework 1.1 and visual studio 2003. All of our database connection strings are stored within the machine config, this was necessary as our web site has 4 environments and the database server has a different name in each. Since the upgrade the...
0
1523
by: N. Demos | last post by:
Hello, I have a custom usercontrol, of which I have two instances of in my aspx page. Both the usercontrol and page have codebehind. In the page codebehind, I want a member variable for each usercontrol. My problem is that I keep getting a compiler error on the usercontrol variables in my page codebehind (BC30002: Type 'CityGeoPosSelectClass'...
4
2431
by: TWEB | last post by:
I think I may have an IIS / ASP.Net Configuration issue that I need some guidance with resolving. Here's the problem: a) I have a .stm file. b) I referenc a .aspx file on this .stm file using a server-side-include directive: <!-- include virtual="../../foobar.aspx"--> c)When the .stm file is rendered: The .aspx file is included, but it...
12
3095
by: titan nyquist | last post by:
I have a class with data and methods that use it. Everything is contained perfectly THE PROBLEM: A separate thread has to call a method in the current instantiation of this class. There is only ever ONE instantiation of this class, and this outside method in a separate thread has to access it. How do i do this?
3
1602
by: Torsten Wiebesiek | last post by:
Hi folks, currently I'm writing image classes for easier handling of Intel's IPP library. My idea is to have to different classes. One class that represents a complete image and deals with all the memeory management stuff, and another class, that is only a tile of the image. Let's call the first MemoryImage, and the second ReferenceImage....
0
7420
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7446
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7778
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6003
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4966
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3476
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3459
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1908
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1033
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.