Use of the MFC visual list control

Source: Internet
Author: User

1. header files should be added

# Include <atlbase. h> 2. The sample Class Wizard binds the m_list variable to the list control.

DWORD
Dwexstyle = lvs_ex_fullrowselect | lvs_ex_gridlines | lvs_ex_headerdragdrop | lvs_ex_oneclickactivate | lvs_ex_flatsb;

M_list.modifystyle (0, lvs_report | lvs_singlesel | lvs_showselalways );
M_list.setextendedstyle (dwexstyle );

M_list.insertcolumn (0, "name", lvcfmt_left, 40); m_list.insertcolumn (1, "gender", lvcfmt_left, 40); m_list.insertcolumn (2, "Age", lvcfmt_left, 40 ); m_list.insertcolumn (3, "Grade", lvcfmt_left, 40); m_list.insertitem (0, "Zhang San"); dimensions (1, "Li Si"); m_list.insertitem (2, "Wang Wu "); cstring str1, str2, str3; str1 = "male"; str2 = "20"; str3 = "Grade 3"; m_list.setitemtext (, str1); m_list.setitemtext (, str2 ); m_list.setitemtext (0, 3, str3); lv_item lvitem;
Lvitem. Mask = lvif_text;
Lvitem. isubitem = 0;
Lvitem. psztext = ""; for (I = 0; I <rnumber; I ++)
{

For (Int J = 0; j <rnum [I]; j ++)
{
Lvitem. iItem = J;
Str1 = R [I] [J]. des_ip.c_str ();
// MessageBox (str1 );

Str2 = R [I] [J]. next_ip.c_str ();
Str3.format ("% d", R [I] [J]. jump_num );
M_list1.insertitem (& lvitem );
M_list1.setitemtext (J, 0, str1 );
M_list1.setitemtext (J, 1, str2 );
M_list1.setitemtext (J, 2, str3 );
} Http://www.cppblog.com/finehai/archive/2009/09/17/96574.html

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.