//向listctrl控件插入edit1框的字符串
void CMyselfDlg::OnButton2()
{
// TODO: Add your control notification handler code here
CString s = "";
GetDlgItem(IDC_EDIT1)->GetWindowText(s);
m_list.InsertItem(0, s, NULL);
}
//想删除listctrl控件中选中的item,不知道用哪个函数取选中的索引号,我下面的代码是从第一项开始删除,但是删除后,下面的item不会自动向上移,难道在vc里这还需要再写代码吗?
void CMyselfDlg::OnButton3()
{
// TODO: Add your control notification handler code here
m_list.DeleteItem(0);
}
void CMyselfDlg::OnButton2()
{
// TODO: Add your control notification handler code here
CString s = "";
GetDlgItem(IDC_EDIT1)->GetWindowText(s);
m_list.InsertItem(0, s, NULL);
}
//想删除listctrl控件中选中的item,不知道用哪个函数取选中的索引号,我下面的代码是从第一项开始删除,但是删除后,下面的item不会自动向上移,难道在vc里这还需要再写代码吗?
void CMyselfDlg::OnButton3()
{
// TODO: Add your control notification handler code here
m_list.DeleteItem(0);
}
此外,如何取得当前选中的item
m_pListCtrl.DeleteItem(m_pListCtrl.GetSelectionMark());
关于不上移,看看你的ListCtrl属性里面的View把他改成List,若改为Report类型的话你还要为ListCtrl设置标头Col