/*
D:\Visual_Studio_repos\MFC\3\
*/
void CMy3Dlg::OnBnClickedButton1()
{
	CString  mString;

	//得到文本框的内容
	GetDlgItemText(IDC_EDIT_1,mString);

	//设置Combo组合框
	mCombo.AddString(mString);

	//默认选中Combo新增的内容
	mCombo.SetCurSel(mCombo.GetCount()-1);

	//默认选中Combo新增的内容
	mList.AddString(mString);
	mList.SetCurSel(mList.GetCount() - 1);
}


void CMy3Dlg::OnBnClickedButton2()
{
	CString mString;
	int nIndex;
	nIndex = mCombo.GetCurSel();
	
	//删除的逻辑操作
	mCombo.DeleteString(nIndex);
	if (nIndex < mCombo.GetCount()) {
		mCombo.SetCurSel(nIndex);
	}
	else {
		mCombo.SetCurSel(nIndex-1);
	}

	mList.DeleteString(nIndex);
	if (nIndex < mList.GetCount()) {
		mList.SetCurSel(nIndex);
	}
	else {
		mList.SetCurSel(nIndex - 1);
	}
}

//实时变化
void CMy3Dlg::OnCbnSelchangeCombo1()
{
	mList.SetCurSel(mCombo.GetCurSel());
}

学习:Combo Box和List Box

相关文章:

  • 2021-08-28
  • 2021-05-31
  • 2022-12-23
  • 2022-02-23
  • 2022-12-23
  • 2022-02-24
  • 2021-12-10
  • 2021-06-22
猜你喜欢
  • 2021-09-11
  • 2022-01-09
  • 2022-12-23
  • 2022-12-23
  • 2021-12-18
  • 2022-12-23
  • 2021-09-02
相关资源
相似解决方案