How to use VC + + list control

Source: Internet
Author: User

A list control can be thought of as a feature-enhanced listbox that provides four styles and can display a column of multi-attribute values at the same time.
MFC uses the CListCtrl class to encapsulate the various operations of a list control.

by calling BOOL Create (DWORD dwstyle, const rect& RECT, cwnd* pParentWnd, UINT NID); Create a window in which you can use some of the following list control's specialized styles:

Lvs_icon Lvs_smallicon lvs_list lvs_report These four styles determine the appearance of the control, and can only select one of them, corresponding to: Large icon display, small icon display, list display, detailed report display

The display character of the Lvs_editlabels node can be edited, and only the first column can be edited for the report style.

Lvs_showselalways also displays the currently selected node when it loses focus.

Lvs_singlesel only one item in the list can be selected

To demonstrate, I'm building a new project.

Open, file, new

Choose MFC APP, project name optional, but must be in English, file location optional

Click Next, select Dialog-based mode, direct point completion

Click the list control and draw a range in the dialog to draw the list control

Right-click List control, point properties

In general, modify the control ID, you can name it yourself

Select report mode in the Style tab, other default

Press CTRL+W, Call out Class wizard, choose Ctestdlg, this is the name of the construction project, own name, may not be the same as me, choose member variable tag

Click Idc_list_info, also named by yourself, may not be the same as mine, add Variable

I have a name, m_xxx,

Click OK

Click on the Message Map tab, first select Ctestdlg, figure 1

Select InitDialog in the message list

Then click on the right edit code

The program will automatically navigate to the code location,

Write code on the last} sign of the code

M_listall.setextendedstyle (Lvs_ex_gridlines | Lvs_ex_fullrowselect);

M_listall.insertcolumn (0, "serial number", Lvcfmt_center);

M_listall.insertcolumn (1, "Column name 1", Lvcfmt_center);

M_listall.insertcolumn (2, "column Name 2", Lvcfmt_center);

M_listall.insertcolumn (3, "column name 3", Lvcfmt_center);

M_listall.setcolumnwidth (0,50);

M_listall.setcolumnwidth (1,80);

M_listall.setcolumnwidth (2,85);

M_listall.setcolumnwidth (3,90);

This completes the initialization, click on the red exclamation mark, compile and allow,

The next section tells you how to insert data.

How to use VC + + list control

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.