| 发表于:2007-10-24 14:43:328楼 得分:0 |
上面已经说了,你重复删除了,两个循环只要一个就可以了,还有,如果下次显示则需要重新初始化列表头。 给你一个函数看看: void testlistview::initlist() { clistctrl &lc = getlistctrl(); dword i = 0; cheaderctrl* pheader = lc.getheaderctrl(); int ncolumncount = pheader-> getitemcount(); for (i = 0;i < ncolumncount;i++) { lc.deletecolumn(0);//删除列表头 } lc.setextendedstyle(lvs_alignleft ¦lvs_ex_headerdragdrop ¦lvs_ex_gridlines ¦lvs_ex_fullrowselect ¦lvs_ex_checkboxes ¦lvs_ex_trackselect); lc.sethovertime(0);//设置鼠标停顿选择时间间隔 dword count=sizeof(_nfieldname)/sizeof(int); cstring strfieldname; for(i=0;i <count;i++) { strfieldname.loadstring (_nfieldname[i]); lc.insertcolumn(i,strfieldname,lvcfmt_left,_ncolwidth[i]);//初始化列表头 } } static int _nfieldname[]={ ids_col_serial,//序号(在string table中定义的列表头) idc_col_name,//名字 }; static int _ncolwidth[]={ 60, 100, }; | | |
|