不要用值传递,改引用传递
CString CInsertRoadInfoDlg::GetListColumnData(CListCtrl&listCtrl,int n)
看个例子C/C++ code// The pointer to my list view control.
extern CListCtrl* pmyListCtrl
CString strText
int nColumnCount = pmyListCtrl->GetHeaderCtrl()->GetItemCount()
// Insert 10 items in the list view control.
for (int i=0i <10i++)
{
strText.Format(TEXT("item %d"), i)
// Insert the item, select every other item.
pmyListCtrl->InsertItem(
LVIF_TEXT|LVIF_STATE, i, strText,
(i%2)==0 ? LVIS_SELECTED : 0, LVIS_SELECTED,
0, 0)
// Initialize the text of the subitems.
for (int j=1j <nColumnCountj++)
{
strText.Format(TEXT("sub-item %d %d"), i, j)
pmyListCtrl->SetItemText(i, j, strText)
}
}
------解决方案--------------------
给你个例子。。。
m_list.InsertColumn(0,"Col 1")
m_list.InsertColumn(1,"Col 2")
m_list.InsertColumn(2,"Col 3")
m_list.InsertColumn(3,"Col 4")
m_list.InsertItem(0,"row1",0)
CString stemp =""
for(int i =0i<4i++)
{
stemp.Format("row 0 %d",i)
m_list.SetItemText(0,i,stemp)
}
m_list.InsertItem(0,"row befor prev",0)
m_list.InsertItem(2,"row after prev",0)
注意InsertItem的第一个参数
结果因该是这样的
row befor prev
row1 row01 row02 row03 row04
row after prev
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)