Use the clistctrl Control

Source: Internet
Author: User

Relationship between Windows controls and corresponding classes: A class is associated with each control and corresponding controls are encapsulated in the class. Clistctrl
Encapsulates the functionality of a "list view contrl". List View Control: displays a collection of items each consisting of an icon (from
An image list) and a label.

Creation: ① The drag control method is equivalent to creating a clistctrl object. ② Dynamic creation: Construct a clistctrl object, which is created in the same way as that of GDI. first construct a class object and then create a list
View control. It can be inferred that all classes associated with Windows objects need to be created in two steps. First, class objects are constructed and then Windows objects are associated. After using GDI, you need to destroy the GDI object, and list
View control does not need to be destroyed.

The List View control can display its content in four different ways, called a view. Icon, small icon, list, and report. Intuitive understanding: in Windows resource manager, the "big icons, small icons, lists, and details" under the "View" tab ". Generally, reports are used. How: set its view attribute or code to set its style.

Change style: After clistctrl is created, its style can be changed at any time. How: ① setview ② getwindowlong get the current control format, and then setwindowlong set the control format.

Distinguish the three words column, item, and subitem: column indicates the column; item indicates the row; subitem indicates the sub-row, which is used with item, that is, the subitem column of the row of the item. There are two ways to add data: ① insert a row or column at a time, and then set its value. ② Insert n rows or columns directly using setcolumnwidth or setitemcount, and then set the value.

Always select item, that is, to make the selected row always highlighted, two ways: ① set attribute always show select to true ② add extended style lvs_showselalways. Difference: ① Select a row and then perform other operations. The background color of the selected row will become dark gray, which is more practical. The method is displayed in dark blue.

Get the column number of the clistctrl: add the nm_click message function of the control:

Nm_listview * pnmlistview = (nm_listview *) pnmhdr;

If (pnmlistview-> iItem! =-1)

{

Cstring strtemp;

Strtemp. Format (_ T ("Click column % d of row % d "),

Pnmlistview-> iItem, pnmlistview-> isubitem );

Afxmessagebox (strtemp );

}

* Presult = 0;

Avoid blinking when updating large data volumes:

M_listctrl.setredraw (false );

// Update content
M_listctrl.setredraw (true );
M_listctrl.invalidate ();
M_listctrl.updatewindow ();

About: Generally, in clistctrl, each column can only display 260 characters, and one or more of them will be truncated. However, the obtained data is correct and the clistctrl class that can edit the subitem.
.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.