We've traced the call and it's coming from inside the house: Grid lines in list view report mode

Raymond Chen

A customer wanted to know how to remove the grid lines from a list view control in report mode. The customer was kind enough to include the source code for the relevant part of the program and drew our attention to the line in the resource file that he believed to be the source of the problem:

CONTROL "",IDC_LIST,WC_LISTVIEW,LVS_REPORT|LVS_SHOWSELALWAYS|
       LVS_SINGLESEL|WS_HSCROLL|WS_TABSTOP|WS_VSCROLL,
       0,40,225,95,WS_EX_CLIENTEDGE

The customer didn’t know it, but that line in the resource file was of no help at all in diagnosing the problem. Fortunately, we found the root cause in the source code provided:

void CListPage::OnInitDialog()
{
  ...
  ListView_SetExtendedListViewStyleEx( hCtrl, 0,
     LVS_EX_FULLROWSELECT |
     LVS_EX_GRIDLINES |
     LVS_EX_LABELTIP |
     LVS_EX_HEADERINALLVIEWS);

The grid lines are there because you explicitly asked for them!

The customer accepted this answer without response. One of my colleagues suspected how this situation came about:

If I may guess, the initial developer of the code did what the spec required at the time, which was to have grid lines. The initial developer then left the company, and a new developer inherited the code.

Now the design team changed their mind and asked for the grid lines to be removed, but the new developer doesn’t know the history of the code and therefore doesn’t know where in the code the grid lines are turned on or even know that the default state for grid lines is off and that you have to turn them on explicitly.

Chances are within the next two months, the design team will change their mind again and the developer will have to put the grid lines back, but at least this time he knows how to do it.

0 comments

Discussion is closed.

Feedback usabilla icon