listctrl是使用非常频繁的一个控件,特别是在数据库编程当中,我们经常将listctrl设置为report格式,然后来显示数据。下面简单介绍list的用法.
首先:
BOOL CXXXDlg::OnInitDialog()
{
................
DWORD dwStyle = m_ctrlList.GetExtendedStyle();
dwStyle |= LVS_EX_GRIDLINES;
m_ctrlList.SetExtendedStyle(dwStyle);
m_ctrlList.InsertColumn(0, "题号", LVCFMT_LEFT, 100);
m_ctrlList.InsertColumn(1, "题目", LVCFMT_LEFT, 100);
m_ctrlList.InsertColumn(2, "选项1", LVCFMT_LEFT, 100);
m_ctrlList.InsertColumn(3, "选项2", LVCFMT_LEFT, 100);
m_ctrlList.InsertColumn(4, "选项3", LVCFMT_LEFT, 100);
m_ctrlList.InsertColumn(5, "选项4", LVCFMT_LEFT, 100);
m_ctrlList.InsertColumn(6, "答案", LVCFMT_LEFT, 100);
m_ctrlList.InsertColumn(7, "帮教内容", LVCFMT_LEFT, 100);
}
然后就是往listctrl里面插入记录条目了。
m_listCtr.InsertItem(0, m_pWageSet->m_id);
m_listCtr.SetItemText(0, 1, str1);
m_listCtr.SetItemText(0, 2, str2);
m_listCtr.SetItemText(0, 3, str3);