ListBox有multiple column的属性但是太难看了 还是用ListCtrl把,用report模式。 ListCtrl的列数是你自己加的,insertcolumn吧! 数据插入末尾是不行的(如果是insertitem())如果你的第一列是从1开始的有序序列,insertitem()之后(显示是逆续)可以调用这个函数从小到大排列,调用语句:m_ListShow.SortItems(MyCompareProc, (LPARAM)&m_ListShow); 函数是: static int CALLBACK MyCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) { // lParamSort contains a pointer to the list view control. // The lParam of an item is just its index. return 1; }
还有,怎么将数据插在末尾呢
CListCtrl::InsertItem
CListCtrl::SetItemText
还是用ListCtrl把,用report模式。
ListCtrl的列数是你自己加的,insertcolumn吧!
数据插入末尾是不行的(如果是insertitem())如果你的第一列是从1开始的有序序列,insertitem()之后(显示是逆续)可以调用这个函数从小到大排列,调用语句:m_ListShow.SortItems(MyCompareProc, (LPARAM)&m_ListShow);
函数是:
static int CALLBACK
MyCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
// lParamSort contains a pointer to the list view control.
// The lParam of an item is just its index.
return 1;
}
m_listCtrl.InsertColumn(0, "第一列", LVCFMT_LEFT, 100);
m_listCtrl.InsertColumn(1, "第二列", LVCFMT_LEFT, 100);将数据插在末尾:
首先用
int nRow = m_listCtrl.GetItemCount();
然后用 nRow 作为行号插入就可以了
m_listCtrl.InsertItem(nRow, "abc");
m_lsitCtrl.SetItemText(nRow, 1, "def"); // 设置第二列