ListBox添加删除

void CCListDemoDlg::OnBtnAdd() 
{
// TODO: Add your control notification handler code here
//添加数据
if (m_num==NULL||m_name==NULL||m_sex==NULL||m_grade==NULL)
{
MessageBox("字段不能为空");
}




int index = m_listview.GetItemCount();
m_listview.InsertItem(index,m_num,0);
m_listview.SetItemText(index,1,m_name);
m_listview.SetItemText(index,2,m_sex);
m_listview.SetItemText(index,3,m_grade);
}


void CCListDemoDlg::OnBtnDelete() 
{
// TODO: Add your control notification handler code here
int index = m_listview.GetSelectionMark();
m_listview.DeleteItem(index);
}

你可能感兴趣的:(C++)