List control with single / double separator lines

Placing row and column seperators in a listview

provided by: 
Originally published at Internet.com


This article describes how to add separator lines (single line or double line) to a list control derived from CListCtrl. This technique requires that the list control is owner drawn. This article also demonstrates how to prevent row selection in a list control.

grid_separator.gif (2590 bytes)

How to do it?



Let's assume that we have a class TVisualListCtrl derived from CListCtrl. Objects of this class correspond to list control resources (each list control must be ownerdrawn). In order to implement support for separator lines, we have to add several features to this class.

Step 1.

Add a public enum type containing the separator line identifiers and 2 public functions for inserting a separator line and checking whether the item is separator or not. class TVisualCtrlList : public CListCtrl { public: enum ESeparator { SEPARATOR_SINGLE, SEPARATOR_DOUBLE }; ..... public: .... BOOL IsSeparator(int row); int InsertSeparator(int row, ESeparator separator = SEPARATOR_SINGLE); };

Also create 2 constant strings (within a class or as local variables in a .cpp implementation file) which are inserted into the list control. These strings have a special meaning to the class implementation since they are actually aliases to separator lines. const CString SingleSeparator = _T("--"); const CString DoubleSeparator = _T("==="); ...

Read article at Internet.com site
Regional Articles
- List control with single / double separator lines Alabama
- List control with single / double separator lines Alaska
- List control with single / double separator lines Arizona
- List control with single / double separator lines Arkansas
- List control with single / double separator lines California
- List control with single / double separator lines Colorado
- List control with single / double separator lines Connecticut
- List control with single / double separator lines DC
- List control with single / double separator lines Delaware
- List control with single / double separator lines Florida
- List control with single / double separator lines Georgia
- List control with single / double separator lines Hawaii
- List control with single / double separator lines Idaho
- List control with single / double separator lines Illinois
- List control with single / double separator lines Indiana
- List control with single / double separator lines Iowa
- List control with single / double separator lines Kansas
- List control with single / double separator lines Kentucky
- List control with single / double separator lines Louisiana
- List control with single / double separator lines Maine
- List control with single / double separator lines Maryland
- List control with single / double separator lines Massachusetts
- List control with single / double separator lines Michigan
- List control with single / double separator lines Minnesota
- List control with single / double separator lines Mississippi
- List control with single / double separator lines Missouri
- List control with single / double separator lines Montana
- List control with single / double separator lines Nebraska
- List control with single / double separator lines Nevada
- List control with single / double separator lines New Hampshire
- List control with single / double separator lines New Jersey
- List control with single / double separator lines New Mexico
- List control with single / double separator lines New York
- List control with single / double separator lines North Carolina
- List control with single / double separator lines North Dakota
- List control with single / double separator lines Ohio
- List control with single / double separator lines Oklahoma
- List control with single / double separator lines Oregon
- List control with single / double separator lines Pennsylvania
- List control with single / double separator lines Rhode Island
- List control with single / double separator lines South Carolina
- List control with single / double separator lines South Dakota
- List control with single / double separator lines Tennessee
- List control with single / double separator lines Texas
- List control with single / double separator lines Utah
- List control with single / double separator lines Vermont
- List control with single / double separator lines Virginia
- List control with single / double separator lines Washington
- List control with single / double separator lines West Virginia
- List control with single / double separator lines Wisconsin
- List control with single / double separator lines Wyoming

Rss   Delicious   Digg   Add To My Yahoo   Add To My Google   Bookmark   Search Plugin

Topics:
Architecture & Design Languages & Tools Project Management Web Services
Database Microsoft & .NET Security Wireless
Java Open Source Techniques XML