<%@ Page language="c#" AutoEventWireup="false" %> SandGrid Documentation

SandGrid User Guide


Back to Table of Contents

Standard Renderers

We ship two renderers with the product: WindowsXPRenderer, which renders grid elements in a style consistent with the operating environment and theme selected by the user or in a Windows XP style if theming is disabled; and Office2007Renderer, which renders grid elements in a style consistent with the various grids in Office 2007. The renderer used by a grid is typically chosen at design-time.

The Office 2007 renderer exposes a number of properties to further customise its appearance. There are in fact properties for changing every specific colour in the table used to draw elements, but it is the properties that change the appearance as a whole that warrant discussion here. The ColorScheme property allows selection of one of the three standard colour schemes: Blue, Silver and Black. ColumnHeaderStyle allows selection of column headers matching either Outlook or Excel. GroupHeaderStyle allows selection of group headers using a divider line, like in the list of email messages in Outlook, or displayed as a button, like in the navigation tree also in Outlook.

The Windows renderer is designed to match the operating environment so it does not provide many properties for customisation. Indeed the only property it exposes for changing colours is the AlternateRowBackgroundColor property, whose use is obvious.

Text Operations

Grids rely heavily on text rendering, and SandGrid is no exception. When writing controls that sit on the Windows Forms model one has to cope with inconsistencies in text rendering, especially with a product such as this that is released for .NET 1.0 as well as .NET 2.0+.

A full discussion of the pros and cons of GDI and GDI+ text rendering is beyond the scope of this document. The TextFormattingInformation structure is our technology-independent method of controlling text formatting in SandGrid, and a GridColumn is responsible for creating an instance of this to control text rendered underneath it. It exposes StringFormat, a field containing an instance of StringFormat to control text rendering under GDI+, and if you're using the .NET 2.0 version of SandGrid, it also exposes TextFormatFlags for controlling GDI text rendering.

The companion to TextFormattingInformation is the IndependentText class in the Rendering namespace. Use the static methods on this to render text in a manner separate from one particular technology. SandGrid of course uses this exclusively internally. Performance of GDI text rendering through this method compared with the standard TextRenderer class is nearly double.

We need to support both kinds of text rendering (rather than one or the other) because of printing. Even when using .NET 2.0 with fast GDI text rendering, GDI+ needs to be used when printing because the .NET printing model is based upon GDI+. SandGrid abstracts this problem away from developers extending it by automating the switchover.


Printing services are made available through the Print, PrintPreview and PageSetup methods on the SandGrid control. The Print method can optionally show a configuration dialog before printing is started. A PrintDocument-derived class is exposed via the PrintDocument property, for the cases where developers need fine-grained access to printing services.

SandGrid provides its printing services via the SandGridPrintDocument class. This class has only one controllable feature: shrinking the print job to fit the width of the printed pages. This is a very useful feature, especially for nested-grid scenarious where depending upon the level of expansion by the user, the data could be very wide. To enable this feature set the ShrinkToFit property of the SandGrid.PrintDocument object to true.