如何在LISTBOX中插入两列?

mm33211 2005-06-16 12:33:15
在LISTBOX中插入一列用的是AddString(str)

那请问插入两列用什么呢,请教了~~
...全文
712 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
cnwolf 2005-06-16
  • 打赏
  • 举报
回复
listbox就一列吧,用listcrtrl多好
yangzhipeng3993 2005-06-16
  • 打赏
  • 举报
回复
调用2遍InsertString不就得了
Kudeet 2005-06-16
  • 打赏
  • 举报
回复
直接用CListCtrl控件吧
qrlvls 2005-06-16
  • 打赏
  • 举报
回复
插入两列:
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"); // 设置第二列
qiaoyangmonitor 2005-06-16
  • 打赏
  • 举报
回复
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;
}
qrlvls 2005-06-16
  • 打赏
  • 举报
回复
首先将 CListCtrl 的属性设为 Report 风格
qrlvls 2005-06-16
  • 打赏
  • 举报
回复
CListCtrl::InsertColumn
CListCtrl::InsertItem
CListCtrl::SetItemText
mm33211 2005-06-16
  • 打赏
  • 举报
回复
那用LISTCTRL怎么控制他的列数呢
还有,怎么将数据插在末尾呢

15,978

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧