Processing duplicates and oddstyles

Stimulsoft Reports.NET discussion
incognito_gbg
Posts: 23
Joined: Wed May 30, 2007 4:15 am

Processing duplicates and oddstyles

Post by incognito_gbg »

Is it possible to have oddstyles and evenstyles for the generated rows in a databand, that uses one style for merged duplicates?

I want something like this.

Row 1 - single item - white background
Row 2 - merged with row 3 - gray background
Row 3 - merged with row 2 - gray background
Row 4 - single item - white background
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Processing duplicates and oddstyles

Post by Edward »

Yes, it is possible.

For this you need declare 2 variables in the report Dictionary:

bool OddLine - to determine changing of the Text value from Row to Row.
string MyVar - to store value of the previous text line.

In the GetValue of the StiText please type the following:

Code: Select all

if (e.Value != MyVar)
{
OddLine = !OddLine;
MyVar = e.Value;
}
HighlightCondition of the Text component should contain the following:

Code: Select all

OddLine
You can see that report in the Demo.exe sample Application. To download it please use link bellow:


Thank you.
Attachments
8.ProcessingDuplicatesAndOddStyle.zip
(3.35 KiB) Downloaded 280 times
incognito_gbg
Posts: 23
Joined: Wed May 30, 2007 4:15 am

Processing duplicates and oddstyles

Post by incognito_gbg »

It does work, but Im having some trouble with the highligt condition. If I use the gray background on the highlight-condition based on the expression "OddLine", then I get to many gray lines. I need someway to retrieve the former rows background-color on the condition, rather than using a specified style/background-color.
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Processing duplicates and oddstyles

Post by Edward »

incognito_gbg wrote:It does work, but Im having some trouble with the highligt condition.
In that case you can use BeforePrint Event of the StiText component for setting its background. You can do this as following:

Code: Select all

Text1.Brush = new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.Silver);
Setting the background in the BeforePrint Event of the StiText component has higher priority than HighLightCondittion.
incognito_gbg wrote:If I use the gray background on the highlight-condition based on the expression "OddLine", then I get to many gray lines. I need someway to retrieve the former rows background-color on the condition, rather than using a specified style/background-color.
It is no problem. All you need is to add your custom counter for the odd lines which are produced by the ProcessingDuplicates property. And then to include this counter in the HighLightCondition.

Also the same result can be achieved without using HighLightCondition.
In the attachment you can get such report template which I've made without using of the HighLightCondition.
Variables:
string MyVar
int LineNumberOdd - counter for the lines after ProcessingDuplicates property.

BeforePrint event of the Text1:

Code: Select all

if ((LineNumberOdd&1)==0)
{
Text1.Brush = new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.Silver);
}
else
{
Text1.Brush = new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.White);
}
GetValue event of the Text1 component:

Code: Select all

if (e.Value != MyVar)
{
LineNumberOdd++;
MyVar = e.Value;
}
If needed you can simply change the logic of drawing the background of the Text1 in the way you need.

Thank you.
Attachments
9.ProcessingDuplicatesAndOddStyle2.zip
(3.44 KiB) Downloaded 243 times
incognito_gbg
Posts: 23
Joined: Wed May 30, 2007 4:15 am

Processing duplicates and oddstyles

Post by incognito_gbg »

First off, I want to thank you for all the help. It is very appriciated. :)

It works quite well now, but Im still having trouble when the lines have more that one column.

If I use your example with the Before Print event and GetValue event on the column thats using the 'Processing Duplicates = merged'-property, then it works perfectly. But when I try to add the event-handles on my other columns, then all rows become gray. If dont add that eventhandler, and just add the colorproperties for text2, text3...etc in the Beforeprint-event for Text 1 (the column with Processing Duplicates = merged'-property), then it still just changes the color for itself and leaves the other columns unchanged.
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Processing duplicates and oddstyles

Post by Edward »

Please send sample to Image for analysis.

Thank you.
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Processing duplicates and oddstyles

Post by Edward »

In that case please set Columns on the Page, not on the Database. If you still need to use columns on the Databand, please set DownThenAcross mode for them in the ColumnDirection property.

Please send sample to Image for analysis.

You may do the modifications in my previous sample.

Thank you.
incognito_gbg
Posts: 23
Joined: Wed May 30, 2007 4:15 am

Processing duplicates and oddstyles

Post by incognito_gbg »

I will send an email later this day as soon as I have time.

With columns, I dont mean that Im using the colum properties for the databand. I mean the generated columns that appear on the report from the Text-controls that I have connected with an XML-file and schema.
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Processing duplicates and oddstyles

Post by Edward »

incognito_gbg wrote:If I use your example with the Before Print event and GetValue event on the column thats using the 'Processing Duplicates = merged'-property, then it works perfectly. But when I try to add the event-handles on my other columns, then all rows become gray.
Please use for this sample latest prerelease build of the StimulReport.Net. The sample will not run on the 2007.1 release version because we've made some enchantments in that direction.

Thank you.
incognito_gbg
Posts: 23
Joined: Wed May 30, 2007 4:15 am

Processing duplicates and oddstyles

Post by incognito_gbg »

Hmm. I´ve tried several different ways of solutions, but I cant get it to work properly.

I use this function in the getValue-event for text1.
if (e.Value != MyVar)
{
LineNumberOdd++;
MyVar = e.Value;
}



And then I use this in the before-print-event.
if ((LineNumberOdd&1)==0)
{
text1.Brush = new Stimulsoft.Base.Drawing.StiSolidBrush
(System.Drawing.Color.White);
}
else
{
text1.Brush = new Stimulsoft.Base.Drawing.StiSolidBrush
(System.Drawing.Color.Silver);
}



But when I change the Before Print-event to this, then background-color for text2 is changed, but not always on the same rows where the background-color for text1 is changed.

if ((LineNumberOdd&1)==0)
{
text1.Brush = new Stimulsoft.Base.Drawing.StiSolidBrush
(System.Drawing.Color.White);
text2.Brush = new Stimulsoft.Base.Drawing.StiSolidBrush
(System.Drawing.Color.White);
}
else
{
text1.Brush = new Stimulsoft.Base.Drawing.StiSolidBrush
(System.Drawing.Color.Silver);
text2.Brush = new Stimulsoft.Base.Drawing.StiSolidBrush
(System.Drawing.Color.Silver);
}

The getValue-event is only specificed for text1 here, ie the one that is using the Process Duplicates.

The thing is that I want text2, text3, text4...etc to always change on the same rows as for text1. I´ve tried using the the examples that have been posted here, but I cant get exactly what I want even with them.

I have mailed a sample now to support [@] stimulsoft.com
Post Reply