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

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:


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,

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.

Comments (18)
  1. asf says:

    He did not even grep the source tree for "Grid", why do people like this get to deal with MS dev's directly and the rest of us with actual questions are stuck with blogs and stackoverflow? :(

  2. frymaster says:

    asf – this is why what microsoft calls "support tickets" cost actual money.  You get to speak to actual developers.

  3. Adam Rosenfield says:

    @asf: Without more information, I'd give him the benefit of the doubt and assume that the word "grid" appeared an enormous number of times in the source tree, which makes finding the relevant one difficult.  Of course, if he'd bothered to look at the documentation for ListView styles (msdn.microsoft.com/…/bb774739%28VS.85%29.aspx and msdn.microsoft.com/…/bb774732%28VS.85%29.aspx), he'd know to search for LVX_EX_GRIDLINES.

  4. asf says:

    @frymaster: So this is their best dev? They had nobody in house that could figure this out? I refuse to believe that they paid to get this fixed!

  5. Dan Bugglin says:

    Interesting that they set their EX styles in the code rather than in the resource file in the first place.  Seems to indicate whoever set up the grid style might not have known about the resource file or how they work.

  6. Skyborne says:

    @asf: Sometimes, even the best developers fail.  My life would be way more awesome if I were perfect.

  7. Frank Cheng says:

    @Dan Bugglin: You can't set extended listview styles in resource file.

  8. Tom says:

    In many cases, the support has already been paid for on a long-term contract.  Since it's free, they might as well use it.

  9. TheFogger says:

    Heh, if the application was written in WPF the design team could do the change themselves :-) The program most likely predates WPF, though.

  10. Troll says:

    How about turning off full row selection in list view list mode beginning with Vista which leaves no space for clicking an empty space? No choice there at all? Drives me mad. (See img89.imageshack.us/…/selectionrectangle.png).

    [You can still right-click the empty space. -Raymond]
  11. Cheong says:

    Part of the reasons that I buy my MSDN subscription is that I might need support in situation like this.

    This is somewhat common in software industry – You're given a project someone has worked on and leaved *written in a language you barely have experience with* (say, just because you mentioned your FYP is written in Java in high school), and told to have one week to get yourself familiar with that and work on. With MSDN subscription's support at least I get support for more than half among the most commonly used languages in the world.

    If you have time, you may dive in MSDN documentation to search for related information. But if you're in rush (say, in extreme situation, I had to face 5 one-man project at once. Two of which in languages that I barely had previous experience), you may just want to get expert to deal with question seems likely to be common, and focus on your tasks.

  12. Troll says:

    Right clicking isn't useful in dialog boxes where the user has to select x files and then click an "Open" button.

    [Now I don't know what you're talking about, but don't bother explaining since you're a troll. -Raymond]
  13. Troll says:

    Yes I will try to explain it. In common dialogs like Load/Open dialog, the user wants to select one or more files and click the Open button to open them. Here the full row selection annoys. Right clicking shows a menu, I don't want to show a context menu, I only want to select items and click Open.

    [I would think full row selection would make it easier to select the items you want to open. What this has to do with grid lines I have no idea. I should just delete this entire comment thread. -Raymond]
  14. Troll says:

    ListView does not have this annoyance in List View List mode before Vista and in Windows 7, ItemsView does not have this annoyance either. Only ListView in Vista and later has this.

  15. POKE53280,0 says:

    @TheFogger: I agree with you: separating UI design from the rest of code (like in WPF philosophy) is a good thing. I wish there was a native C++ equivalent of WPF.

  16. Troll says:

    If you *drag and select* files (drag from an empty area), full row selection makes it very difficult. Therefore this full row selection in List view list mode should be a configurable extended style like there is LVS_EX_FULLROWSELECT for report mode.

  17. c++cli says:

    you can use wpf from c++

  18. leak says:

    Why does ListView leak memory when adding strings and substrings? Memory isn't released when destroying the control.

    [I wonder if you could possible be more vague. But here is not the place to discuss the issue. (If you insist on doing it here, you can wait until the Suggestion Box reopens in a few years.) -Raymond]

Comments are closed.

Skip to main content