Share via


Creating a List View Control (Windows CE 5.0)

Send Feedback

A list view is a common control that displays a collection of items, such as files or folders. Each item has an icon and a label. A user can choose whether to have the items displayed as large icons, small icons, a list, or a detailed list. You can design list views so that a user can drag an item to a new location within the list view or sort the collection by tapping a column header. The following screen shot shows an image list in list view.

ms926185.listviewce(en-us,MSDN.10).gif

To create a list view control

  1. Specify the WC_LISTVIEW class in the lpClassName parameter of the CreateWindowEx function.

    This class is registered when the DLL for the common control DLL is loaded. Use the InitCommonControls function to ensure that this DLL is loaded. When you register the list view class by using the InitCommonControlsEx function, specify the ICC_LISTVIEW_CLASSES flag as the dwICC member of the INITCOMMONCONTROLSEX structure that you pass in the lpInitCtrls parameter.

  2. Specify a list view style in the dwStyle parameter of the CreateWindowEx function.

You can speed up the creation of large list views by disabling the painting of the list view before adding the items. You disable the painting of the list view by sending a WM_SETREDRAW message with the redraw flag in wParam set to FALSE. When you are finished adding items, you can re-enable painting by sending WM_SETREDRAW with the wParam redraw flag set to TRUE. Before inserting items, send the LVM_SETITEMCOUNT message with the cItems parameter set to the number of items in question. When you send this message, the list view will allocate the memory that it needs all at once, instead of having to reallocate more memory incrementally as the internal data structures grow.

You can change the view type after a list view control has been created. To retrieve and change the window style, use the GetWindowLong and SetWindowLong functions. To determine the window styles that correspond to the current view, use the LVS_TYPEMASK value.

You can control the way in which items are arranged in icon view or small-icon view by specifying either the LVS_ALIGNTOP window style, which is the default style, or the LVS_ALIGNLEFT window style. You can change the alignment after a list view control has been created. To isolate the window styles that specify the alignment of items, use the LVS_ALIGNMASK value.

When a user clicks on a list view control that is editable, the list view control notifies the parent application that it is entering into the Edit mode by sending the LVN_BEGINLABELEDIT notification. If the application accepts the edit, the user can make any edits necessary. After the user dismisses from edit mode, the list view control sends the LVN_ENDLABELEDIT notification to the parent application.

Windows CE does not support hot tracking, hover selection, background images, or ToolTips for a list view.

See Also

Working with Common Controls | Creating Controls

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.