Share via


Changing List Control Styles

OverviewSample

You can change the window style of a list control () at any time after you create it. By changing the window style, you change the kind of view the control uses. For example, to emulate the Explorer, you might supply menu items or toolbar buttons for switching the control between different views: icon view, list view, and so on.

For example, when the user selects your menu item, you could make a call to to retrieve the current style of the control and then call to reset the style. For more information, see in the Platform SDK.

Available styles are listed in . The styles LVS_ICON, LVS_SMALLICON, LVS_LIST, and LVS_REPORT designate the four list control views.

Extended Styles

In addition to the standard styles for a list control, there is another set, referred to as extended styles. These styles, discussed in in the Platform SDK, provide a variety of useful features that customize the behavior of your list control. To implement the behavior of a certain style (such as hover selection), make a call to , passing the needed style. The following example demonstrates the function call:

m_myListCtrl.SetExtendedStyle(LVS_EX_TRACKSELECT | LVS_EX_ONECLICKACTIVATE);

Note   For hover selection to work, you must also have either LVS_EX_ONECLICKACTIVATE or LVS_EX_TWOCLICKACTIVATE turned on.

See Also   Windows Common Controls and MFC Classes