怎样使CListctrl第一列中的各项居中显示

怎样使CListctrl第一列中的各项居中显示

我的代码: 
m_list.InsertColumn(0, "1 ",LVCFMT_CENTER,80); 
m_list.InsertColumn(1, "2 ",LVCFMT_CENTER,80); 
m_list.InsertColumn(2, "3 ",LVCFMT_CENTER,80); 

m_list.InsertItem(0, "aaa "); 
m_list.SetItemText(0,1, "bbb "); 
m_list.SetItemText(0,2, "ccc "); 

m_list.InsertItem(1, "xxx "); 
m_list.SetItemText(1,1, "yyy "); 
m_list.SetItemText(1,2, "zzz "); 

同样是“LVCFMT_CENTER”,为什么第二列和第三列都能居中,可第一列实际显示就是偏左呢?
==========================================================================================
If   a   column   is   added   to   a   list-view   control   with   index   0   (the   leftmost   column)   and   with   LVCFMT_RIGHT   or   LVCFMT_CENTER   specified,   the   text   is   not   right-aligned   or   centered.   The   text   in   the   index   0   column   is   left-aligned.   Therefore   if   you   keep   inserting   columns   with   index   0,   the   text   in   all   columns   are   left-aligned.   If   you   want   the   first   column   to   be   right-aligned   or   centered   you   can   make   a   dummy   column,   then   insert   one   or   more   columns   with   index   1   or   higher   and   specify   the   alignment   you   require.   Finally   delete   the   dummy   column.
==========================================================================================
十分感谢! 
可是如果只是插入文本的话,是好用的,我给加入一个Image   List后就不好用了。 
这个CListCtrl真是麻烦! 
这是俺的代码,大侠帮给看看: 

//插入一些colomn先,然后 
m_list.SetImageList(&m_Image,LVSIL_SMALL); 
m_list.DeleteColumn(0); 
m_list.InsertItem(0, " ");//默认就给第一列加上图像了,我考 
m_list.SetItem(0,0,LVIF_IMAGE,NULL,-1,0,0,0);//把第一列图像去掉 
m_list.SetItemText(0,0, "hahaha "); 
结果header居中了,可是“hahaha”并没有居中,是在中间偏右的地方,你点它,他还会往左动一下,我真是服了。什么乱七八糟的。 
==========================================================================================
LVCOLUMN lv_column; 
memset(&lv_column,0,sizeof(LVCOLUMN)); 
lv_column.mask   =   LVCF_TEXT   |   LVCF_FMT; 
m_list.SetExtendedStyle(   LVS_EX_GRIDLINES   |   LVS_EX_FULLROWSELECT   ); 
for(   int   i=0   ;   i <6   ;   i++   ) 

                    lv_column.fmt   =   LVCFMT_CENTER; 

=======================================================
m_list.DeleteColumn(0); 
应该放在操作的最后

你可能感兴趣的:(怎样使CListctrl第一列中的各项居中显示)