编程论坛
注册
登录
编程论坛
→
VC++/MFC
我是新手,用vc6mfc编对话框 想问问list box 控件怎么用啊?详细点介绍啊。万分感谢。。
红绿灯
发布于 2011-10-16 18:09, 675 次点击
我想把从编辑框录入的数据 保存在顺序表中并且能动态的显示在 list box上 具体该怎么实现啊?
1 回复
#2
红色警戒
2011-10-16 22:56
程序代码:
//
设置列表控件的风格,使其可以整行选择和网格条纹
DWORD style=m_ListData.GetExtendedStyle();
m_ListData.SetExtendedStyle(style|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
style=m_ListData2.GetExtendedStyle();
m_ListData2.SetExtendedStyle(style|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
//
初始化列表控件
m_ListData.InsertColumn(
0
,
"
序号
"
);
m_ListData.SetColumnWidth(
0
,
45
);
m_ListData.InsertColumn(
1
,
"
地点
"
);
m_ListData.SetColumnWidth(
1
,
100
);
//
方向
m_ListData.InsertColumn(
2
,
"
方向
"
);
m_ListData.SetColumnWidth(
2
,
80
);
//
车道
m_ListData.InsertColumn(
3
,
"
车道
"
);
m_ListData.SetColumnWidth(
3
,
0
);
str.Format(
"
%d
"
, count +
1
);
//
插入序号
m_ListData.InsertItem(count, str);
//
因为列表控件中0号索引项为第一项所以要加1
//
地点
m_ListData.SetItemText(count,
1
, strAddressInCombo);
//
方向
m_ListData.SetItemText(count,
2
, strDirectionInCombo);
1