Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
7
Erster Beitrag:
vor 6 Monaten, 1 Woche
Letzter Beitrag:
vor 6 Monaten, 1 Woche
Beteiligte Autoren:
Garry Allen, Ned!, Piet van Zanten, Al

Shade alternate rows in a report

Startbeitrag von Garry Allen am 13.02.2017 18:53

As usual, seems simple but I can't figure out how to do it!
Garry

Antworten:

Hello Garry

Here is one method.
I use a global variable to trigger a static in the body row of each report. Most of my reports are selected from a table menu that is automatically generated from a reports data file and the ability to show the background on rows is stored in that file but can be changed on the fly.

Whatever method you eventually use to apply the colour the process boils down to counting the report body rows and the using the IsEven function colour the even rows.
You can have a defined colour or change the colour as you go - all my colours are defined in a file.

This is the global procedure I use:

PROCEDURE RepBodyCount(LBackgroundStatic = "RepBodyBackground",LBodyBackGround = True)

IF GReportdisplaybackground = True
GRepBodyLineCount ++
IF LBodyBackGround
//the report must contain a static called "RepBodyBackground"
IF IsEven(GRepBodyLineCount) //IntegerPart(GRepBodyLineCount /2) = (GRepBodyLineCount/2)
//{LBackgroundStatic}..state = grayed; {LBackgroundStatic}..Visible=True
{LBackgroundStatic}..Visible=True
{LBackgroundStatic}..BrushColor = SysInfo3.RepBodyBGrndColour
ELSE
{LBackgroundStatic}..Visible=Faux
END
END
ELSE
{LBackgroundStatic}..Visible=False

END



The body row of each report just has the static to display the colour and a call to RepBodyCount() in the "Before Printing Block_Body" event.

Regards
Al

von Al - am 13.02.2017 19:11
Wow... I was thinking that I just couldn't find the right style for the report. After all, if I just use the wizard for a table report and pick GenSteel as a style, the report automatically has alternate rows shaded. (Although I see nothing in the code that would do it)

However, your reply gave me a clue:
First, I grouped all the controls in the body block called BodyGroup
Then I put in the report initialization code:
"gbEvenRow is boolean = False"

and in the Before Printing Body code I put
F gbEvenRow THEN
BodyGroup..BrushColor = LightGray
ELSE
BodyGroup..BrushColor = Transparent
END
gbEvenRow = NOT gbEvenRow

Presto - it works!
Thanks for your help.
Garry

von Garry Allen - am 15.02.2017 04:13
Hi Garry,

This is possible in the Style options for the table control on the report.

See image for where this is...

Thanks
Ned!

[attachment 2280 rows.png]

von Ned! - am 15.02.2017 15:18
Thanks Ned. I have never seen that screen. What version are you using? I'm using WD20.
Garry

von Garry Allen - am 15.02.2017 19:54
This screenshot is from WD21. Perhaps it was one of the 921 new features?

Its the description window of a table control within a report.

Thanks
Ned!

von Ned! - am 16.02.2017 10:56
Hi,

The feature Ned describes has been there at least from version 16.

Regards,.
Piet

von Piet van Zanten - am 16.02.2017 11:37
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.