ClistCtrl use detailed explanation

xiaoxiao2021-03-06  14

1. First to introduce REPORT type CListCtrl: First, use the following statement sets the style CListCtrl: DWORD SetExtendedStyle (DWORD dwNewStyle); wherein represents LVS_EX_CHECKBOXES added CheckBox LVS_EX_FULLROWSELECT represents select an entire row represents LVS_EX_GRIDLINES form lines added

If the LVS_EX_CHECKBOXES property is set, you can use the BOOL getCheck (int NITEM) const; if you get a row Checked.

You can delete the previous thing with the following statement: for (int K = 2; k> = 0; k -) // Note that you want to delete it before, otherwise M_ListCtrl.deleteColumn (k); m_listctrl.deletellItems ();

New columns with the following statement: m_listctrl.insertColumn (0, _T ("file name"), lvcfmt_image | lvcfmt_left); m_listctrl.insertColumn (1, _t ("instrument category")); m_listctrl.insertcolumn (2, _t (" Project category ")); where LVCFMT_IMAGE represents the icon can be added in the first column. If you don't want to be icon, you can delete it.

Then set the column width: for (j = 0; j <3; j ) m_listctrl.setColumnWidth (j, 100); the following is added to the icon, if you do not need icon, you can skip this step. Note that only the first addition, if you join multiple additions! First join the declaration in the header file: CIMAGELIST M_IMAGELIST; this is necessary, if you join in a function of CPP Due to the end of the life period, the effect is automatically released, the effect is that the icon can't be seen in the list, only a white square . Belck CIMAGELIST and bind it into the CListCtrl, this is not the icon in CImageList, just a container: static int flag = 2; if (Flag == 2) {// only calls setimagelist, otherwise the error m_imagelist. Create (128, 128, ILC_COLORDDB | ILC_MASK, 20, 1); M_ListCtrl.setimagelist (& m_imagelist, lvsil_small);} Flag = (Flag 1)% 2; if ClistCtrl has been used, once added icon, then To delete image for (int kk = 0; kk

2. If it is a CListCtrl of the Icon type, you have to do a little change: put the code of the bound icon set by setimagelist (& m_imagelist, lvsil_small); change to setimagelist (& m_imagelist, lvsil_normal); use INSERTITEM (i, mainset.m_filename) , i); do not have to setItemText (i, 1, type);

转载请注明原文地址:https://www.9cbs.com/read-49651.html

New Post(0)