Sunday, November 30, 2008

Displaying a Striped List

It is quite common for lists of information displayed in a web page to present a striped color pattern.  Such a pattern is useful for enhancing the reader's ability to keep track of what is written in a single line.

The picture bellow is a screenshot of an application that is using this technique.



It is quite easy to produce such an effect using a Morfik continuous form, by adding a few lines of code to a server side event of the Detail Band.  The basic trick is to have a Rectangle control behind everything that is on the Detail band and then make it visible or not, on a per row basis.

The following code snipped, assigned to the band's OnBeforePrint event does exactly that.
Procedure ListArticles.DetailBeforePrint(Sender: TWebControl; Canvas: TWebCanvas; Var Print: Boolean);
Begin
    If LineNo mod 2 = 0 then
        DetailStripedBackground.Visible := true
    else
        DetailStripedBackground.Visible := False;
End;

No comments:

Post a Comment