如题,list control初始化代码如下 CDialog::OnInitDialog();
m_list_zzcs.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_HEADERDRAGDROP|LVS_EX_ONECLICKACTIVATE|LVS_EX_GRIDLINES);
m_list_zzcs.InsertColumn(0,"序号",LVCFMT_CENTER,50,0);
m_list_zzcs.InsertColumn(1,"菜名",LVCFMT_CENTER,80,1);
m_list_zzcs.DeleteAllItems();//列表控件重新选择时初始化清空
………………
//添加行号,将int转化为string
CString string;
string.Format("%d",i+1); 
m_list_zzcs.InsertItem(i,"");
m_list_zzcs.SetItemText(i,0,"xh");
m_list_zzcs.SetItemText(i,1,"zzjc");
………………
return TRUE;  运行时,第一行的“序号”、“菜名”是居中显示的,但第二行是左对齐的,不知道怎么样使第二行也居中对齐,请高手指点!谢谢!列表控件第二行居中

解决方案 »

  1.   

    LVCFMT_CENTER 
     Text is centered. 
     设置LVCOLUMN的fmt为LVCFMT_CENTER 
      

  2.   

    http://blog.csdn.net/j6915819/article/details/8135220
      

  3.   

    没看明白,请看一下上面附的代码,在插入列的时候,我已经设置LVCFMT_CENTER 了……能说的再详细些吗?
      

  4.   

    The index of the new column if successful or -1 otherwise.看一下返回值!
      

  5.   

    The leftmost column in a list view control must be left-aligned.