Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to control the line object of crystal report in C#?

Status
Not open for further replies.

newbie14

Technical User
Feb 14, 2009
81
MY
Dear All,
I am doing a dynamic report which will show the columns based on a selection done. So for the columns name I am using the parameter fields of crystal report. So those column which are empty I do the settings as below and those columns will not appear. So this I can control dynamically. The problem is that between this parameter fields I have a line object which I cant control dynamically. Is there any way I can control it too? Thank you.
paramField = new ParameterField();
paramField.Name = "ot" + i;
paramDiscreteValue = new ParameterDiscreteValue();
paramDiscreteValue.Value = "";
paramField.CurrentValues.Add(paramDiscreteValue);
//Add the paramField to paramFields
paramFields.Add(paramField);
 
pretty sure you cannot. i have tried this in the past and was not successful. You can control text, formulas and the like, but they have to exist at design time and I could only manipulate the content, not the presentation.

CR uses design time (opposed to runtime) formatting/layout. If you get this working I would be interested in the code to get this working, but I don't think it's possible.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
Dear Jason,
Well thank you for sharing your experience. I have been having the same problem for my coloring of alternate rows. So besides crystal report what else do you suggest which can handle things dynamically. Because if you look into my scenario now all I have to put the at design time like the total of columns so my report cant be said fully dynamic is just semi-dynamic. Any suggestion please share.
 
report cant be said fully dynamic is just semi-dynamic
it either is or is not :)

I would review the requirements and why you are making a dynamic report layout. It may be that design 3 to 4 report layouts and swapping the datasource is an option.

for example say you have
Customer Id
Customer Name
Jan Sales
...
Dec Sales.

then you have
Contact Id
Contact Name
Jan Sales
...
Dec Sales.

and finally
Broker Id
Broker Name
Jan Sales
...
Dec Sales.

you could create a generic object to represent the data source
Code:
class MyReportDto
{
   public long Id {get;set;}
   public string Name {get;set;}
   public double Jan {get;set;}
   ...
   public double Dec {get;set;}
}
use this dto to bind to the report.

Then you can have 3 different objects to fetch the data for the report
CustomerDataSourceForReport, ContactDataSourceForReport, BrokerDataSourceForReport. All three can inherit from
Code:
interface IDataSourceForMyReport
{
     IEnumerable<MyReportDto> GetDataForReport();
}
each implmentation will query the database differently and return the proper data structure for the report.

maybe something like this could apply to your situation.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
Dear Jason,
Ok my requirement is like this cause I have tried to put by vertical is difficult to make comparison. So what I want say for example comparion of employee sales comparison on a daily basis based on a range of date. So on the horizontal represent the employee names. So vertical will show sales data for each employee. So my report is not fixed on the number of columns that represent the employee name. So say if I choose 5 employee then I want 5 column, if I choose 10 employe then I want 10 column etc. So how can I achieve this via windows form C# application. Thank your for time really appreciate Jason.
 
I'm having difficultly understanding your description. since a picture is worth 1000 words, do you mean this...
[tt]
date | john doe | mary jane | joe cool
---------+----------+-----------+---------
01-02-09 | 100 | 200 | 1000
01-03-09 | 200 | 300 | 2000
01-04-09 | 150 | 250 | 3000
[/tt]
this is a pivot table.
if your query produces data like this
[tt]
name | date | total
----------+----------+-------
john doe | 01-02-09 | 100
john doe | 01-03-09 | 200
john doe | 01-04-09 | 150
mary jane | 01-02-09 | 200
mary jane | 01-03-09 | 300
mary jane | 01-04-09 | 250
joe cool | 01-02-09 | 1000
joe cool | 01-03-09 | 2000
joe cool | 01-04-09 | 3000
[/tt]
then use the pivot table feature in crystal. for more help with the pivot table feature use forum767 or forum149.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
Dear Jason,
The first picture is what I required. Infact I already done but the problem now my maximum columns have been set during design time. What I required is something pure dynamic? Thank you.
 
this is dynamic. CR would handle pivoting date/name, you supply the raw data.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
Dear Jason,
So with pivoting is it possible to have the columns dynamically generated. Can I have any example on this basis ? Another thing is that the paper size in CR have to be decided first right so how can the columns grow dynamically ? Thank you.
 
spike an example and see what the results are. I'm sure there are example on the net. As for introducing paper size... this is a new variable and i'm not sure what the impact of that has on pivot tables. but again, spike a simple example and work through the pain points.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top