MFCコントロール - コンボボックス
提供: MochiuWiki : SUSE, EC, PCB
選択位置を取得する
<syntaxhighlight lang="c++">
CComboBox* pComboBox=(CComboBox*)GetDlgItem(IDC_COMBO);
int index = pComboBox->GetCurSel(); // 現在の選択位置を取得
if(index != CB_ERR )
{ // 指定値が不正な場合や選択されていない場合
TRACE(index);
}
</source>
選択したアイテムを削除する
<syntaxhighlight lang="c++">
CComboBox* pCombo=(CComboBox*)GetDlgItem(IDC_COMBO);
int index = pCombo->GetCurSel(); // 現在の選択位置を取得
if(index != CB_ERR)
{ // 指定値が不正な場合や選択されていない場合
pCombo->DeleteString(index);
}
</source>
全てのアイテムを削除する
<syntaxhighlight lang="c++"> CComboBox* pCombo=(CComboBox*)GetDlgItem(IDC_COMBO); pCombo->ResetContent(); </source>