1.初始化并给默认值

//初始化列表框,并给默认选择
((CListBox*)GetDlgItem(IDC_LIST1))->AddString("1");
((CListBox*)GetDlgItem(IDC_LIST1))->AddString("2");
((CListBox*)GetDlgItem(IDC_LIST1))->AddString("3");
((CListBox*)GetDlgItem(IDC_LIST1))->AddString("4");
((CListBox*)GetDlgItem(IDC_LIST1))->SetCurSel(2);

2.读取

//列表框
void CDialogDlg::OnButton5()
{
    // TODO: Add your control notification handler code here
    int index;
    index=((CListBox*)GetDlgItem(IDC_LIST1))->GetCurSel();//获取光标所在位置
    ((CListBox*)GetDlgItem(IDC_LIST1))->GetText(index,m_list);
    MessageBox(m_list);
}

相关文章:

  • 2021-07-26
  • 2021-06-11
  • 2022-12-23
  • 2022-12-23
  • 2022-01-02
  • 2022-12-23
  • 2021-06-20
猜你喜欢
  • 2022-12-23
  • 2021-07-16
  • 2021-07-03
  • 2021-10-22
  • 2021-12-17
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案