MFC Records CListCtrl Learning using

Source: Internet
Author: User

1. Icon mode icons

2. Small Icon mode Small icon

3. List mode lists

4. Reporting Mode report

Take the report here as an example:

List style and extended style content:

LONG Lstyle; Lstyle= GetWindowLong (M_list.m_hwnd, Gwl_style);//gets the current window styleLstyle &= ~lvs_typemask;//Clear display mode bitLstyle |= Lvs_report;//Set StyleSetWindowLong (M_list.m_hwnd, Gwl_style, lstyle);//Set StyleDWORD dwstyle =m_list.        GetExtendedStyle (); Dwstyle|= Lvs_ex_fullrowselect;//Select a full row highlight (only applicable to Listctrl with report style)Dwstyle |= Lvs_ex_gridlines;//grid lines (only for Listctrl with report style)Dwstyle |= lvs_ex_checkboxes;//Generate CheckBox control before itemM_list. SetExtendedStyle (dwstyle);//set the extension style

First create an MFC project-based dialog box, complete

Then delete the extra stuff, add a listctrl-> Add the variable M_listctrl add the initialization Listctrl code at the initialization of the program.

    //set Listctrl style with the entire row selected and the grid state setM_listctrl.setextendedstyle (lvs_ex_checkboxes| Lvs_ex_fullrowselect |lvs_ex_gridlines); //0, title start bit, content, content alignment, title widthM_listctrl.insertcolumn (0, _t ("Title 1"), Lvcfmt_left, -); M_listctrl.insertcolumn (1, _t ("Title 2"), Lvcfmt_left, the); M_listctrl.insertcolumn (2, _t ("Title 3"), Lvcfmt_left, -); M_listctrl.insertcolumn (3, _t ("Title 4"), Lvcfmt_left, -); M_listctrl.insertcolumn (4, _t ("Title 5"), Lvcfmt_left, -); //Add Column ContentsM_listctrl.insertitem (0, _t ("5552"));//first item of content, index starting from 0,M_listctrl.setitemtext (0,1, _t ("Little Goblin"));//The first item, the second one, the analogy.M_listctrl.setitemtext (0,2, _t ("-127.5225")); M_listctrl.setitemtext (0,3, _t ("50.551")); M_listctrl.setitemtext (0,4, _t ("108.555"));

Common Listctrl functions
/*Advanced List control Listctrl class in MFC associated with: CListCtrl report style Listctrl common actions: 1, Add column header header: InsertColumn 2, get and set column width: getcolumnwidth, Setcolumnwidth 3, add a line: InsertItem, Setitemtext 4, get and set the unit text: GetItemText, Setitemtext 5, allow multiple rows to be selected,  Gets the number of rows selected: Getselectedcount 6, single row selected, gets the selected line: Getselectionmark 7, select a row: SetItemState (n, lvis_selected, lvis_selected); 8. Gets whether the state of a row is checked: GetItemState (n, lvis_selected) = = lvis_selected 9, delete all rows: Deleteallitems 10, delete the specified column: DeleteColumn 11, Delete the specified line: DeleteItem 12, gets and sets the background color of the list control: GetBkColor, SetBkColor 13, get and set text background color: Gettextbkcolor, Settextbkcolor 14, Get and set text foreground: GetTextColor, SetTextColor 15, get and set Check:getcheck, SetCheck 16, Get and set icon list: GetImageList, SetImageList 17, Get and set line append data: GetItemData, SetItemData 18, get and set extended style styles: GetExtendedStyle, SetExtendedStyle 19, Set positive row check with gridlines: SetExtendedStyle (Lvs_ex_fullrowselect |  Lvs_ex_gridlines);  20, let Listctrl support the function of editing: ①, set the edit Labels in the attribute to True;②, respond to the control's Lvn_ednlabeledit message, add the following code: CString strText;  M_listctrl.geteditcontrol ()->getwindowtext (StrText); M_listctrl.setitemtext (PDISPINfo->item.iitem, Pdispinfo->item.isubitem, StrText);  */




MFC Records CListCtrl Learning using

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.