CGXGridParam::SetNewGridLineMode

void SetNewGridLineMode(BOOL b);

b

TRUE if mode shall be enabled; FALSE otherwise.

Remarks

Choose between the old and the new grid line drawing in Objective Grid.

The new grid line drawing mode in Objective Grid, allows you to give the grid a more professional look. The new drawing mode lets you easily switch between solid, dotted and dashed grid lines and allows you to remove the borders between the column and row headers.

The major difference between the two drawing modes is the drawing of the grid lines in a cell. With the old drawing mode, the grid lines were drawn at the top of each row and the left of each column. That means for the drawing of each cell one pixel at the top and at left side of the cell was removed. For example, if the rectangle for a cell is (left = 30, top = 30, bottom = 60, right = 100), the cell contents were drawn in the rectangle (left = 31, top = 31, bottom = 60, right = 100). The top and left pixels were reserved for the grid line.

With the new grid line drawing mode, the grid lines are drawn at the bottom of each row and at the right side of each column. In the above example, this means that the cell contents are drawn in the rectangle (left = 30, top = 30, bottom = 59, right = 99).

This new drawing technique gives the following benefits:

  • The rightmost border of the grid no longer needs to be an “extra” line. You can customize or turn off the rightmost border just like any other grid line.

  • The first non-header column or row does not show an extra border on the left or upper side of the grid area.

  • When you choose to disable the drawing of grid lines for row and column headers, the grid lines are in sync with the bottom-right shadow of the 3d-headers. With the old drawing technique, it looks ugly when you remove the border between the headers because the black shadow is on the bottom-right pixels of the cell, but the grid lines are drawn at leftmost pixel of each cell.

  • When you turn off the drawing of borders for individual cells with SetBorder(gxBorderTop, CGXPen().SetStyle(PS_NULL)), the cell contents will not move one pixel (to the top and to the left) anymore.

Here is how you can give an individual grid the new look:

      // Enable the new grid line drawing
      GetParam()->SetNewGridLineMode(TRUE);
         // use dotted grid lines
      GetParam()->SetGridLineStyle(PS_DOT);
         // and don't draw grid lines between header cells
      ChangeColHeaderStyle(CGXStyle().SetBorders(gxBorderAll, CGXPen().SetStyle(PS_NULL)));
      ChangeRowHeaderStyle(CGXStyle().SetBorders(gxBorderAll, CGXPen().SetStyle(PS_NULL)));

If you want to use the new drawing as default for all grids in your application, you should call GXSetNewGridLineMode() in the InitInstance method of your application.

Example:

BOOL CGridSampleApp::InitInstance()
{
   ...
   GXInit(); // initializes library and resources
   GXSetNewGridLineMode(TRUE);   // use smarter grid lines (and dotted)
   ...

Note: The reason Objective Grid still uses the old drawing technique as default is to be compatible with earlier versions. If you did assign a border to the top of a cell with SetBorder(gxBorderTop, CGXPen(style, width, color)), no grid line was visible at the top for the specific cell, because the specified border was drawn over the grid line. With the new drawing mode, the grid line is drawn at the bottom of the cell and therefore will not be hidden by the border at the top, which can look ugly.

With the new grid line mode, assigning a border to the bottom of the cell (SetBorder(gxBorderBottom, CGXPen(style, width, color)) will make the grid line disappear. If you assign CGXPen().SetStyle(PS_NULL), the grid line will simply disappear, and the whole rectangle of the cell will be used as drawing area for the cell contents.

See Also

 CGXGridParam::SetGridLineStyle  GXSetNewGridLineMode

CGXGridParam

 Class Overview |  Class Members