CMainFrame* pMainFrm =(CMainFrame*)AfxGetApp()->m_pMainWnd;
CStateListView *lv1=(CStateListView*)(pMainFrm->m_wndSplitter1.GetPane(1,0));
CListCtrl& lc1=lv1->GetListCtrl();
lc1.DeleteAllItems();
for(int i=0;i<CStateListView::ColNum;i++)
lc1.DeleteColumn(0);
CStateListView::ColNum=0;
lc1.SetExtendedStyle(LVS_EX_GRIDLINES); lc1.InsertItem(0,_itoa(18,buffer,10));
lc1.InsertItem(0,_itoa(30,buffer,10));
lc1.InsertItem(0,_itoa(7,buffer,10));

出来第一列应该是18,30,7啊
但显示出来却是7,30 ,8 
我在用循环插入数据,但第一列的序号总是不对,而且我要插入几百行数据,但一般插入2行下面的行就没有显示了,是不是没有给控件设置什么风格啊,还是怎么回事情啊帮帮我啊!

解决方案 »

  1.   

    你每一个都是Insert到0的位置上,当然出来的顺序是7,30 ,8阿
      

  2.   

    int InsertItem( int nItem, LPCTSTR lpszItem, int nImage );nItem
    Index of the item to be inserted.同意楼上的。
      

  3.   

    InsertItem第一个参数表示插入的位置,你都用0,当然都插到第一位了,前面插的都挤到后面去了。
    lc1.InsertItem(0,_itoa(18,buffer,10));
    lc1.InsertItem(1,_itoa(30,buffer,10));
    lc1.InsertItem(2,_itoa(7,buffer,10));
      

  4.   

    int i = lc1.InsertItem(0,_itoa(18,buffer,10));
    lc1.InsertItem(i,_itoa(30,buffer,10));
    这样才能保证30插在18后面。至于“插入几百行数据,但一般插入2行下面的行就没有显示了”,这个lz还是要贴出代码来看看啊~~
      

  5.   

    lc1.InsertItem(lc1.GetItemCount(), strText);