【发布时间】:2019-03-13 16:23:59
【问题描述】:
我有这个代码:
void CChristianLifeMinistryEditorDlg::UpdateDatesCombo()
{
for (int iDate = 0; iDate < m_cbDates.GetCount(); iDate++)
{
auto *pEntry = (CChristianLifeMinistryEntry*)m_cbDates.GetItemDataPtr(iDate);
if (pEntry != nullptr)
{
COMBOBOXEXITEM cmbItem;
CString strDateOriginal = _T("");
CString strDateNew = FormatWeekOfMeetingText(pEntry->GetMeetingDate());
// Get the existing item from the combo
cmbItem.mask = CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_TEXT | CBEIF_LPARAM;
cmbItem.iItem = iDate;
cmbItem.pszText = strDateOriginal.GetBuffer(_MAX_PATH);
cmbItem.cchTextMax = _MAX_PATH;
m_cbDates.GetItem(&cmbItem);
strDateOriginal.ReleaseBuffer();
// Update the text
strDateNew = FormatWeekOfMeetingText(pEntry->GetMeetingDate());
cmbItem.pszText = strDateNew.GetBuffer(_MAX_PATH);
m_cbDates.SetItem(&cmbItem);
strDateNew.ReleaseBuffer();
}
}
}
它工作正常,可以正确地将下拉列表从一种语言更改为另一种语言。
但是,在我将鼠标悬停在控件上之前,组合中的现有值不会更新。
我尝试过m_cbDates.UpdateWindow 并没有什么区别。
我看到了这个question,但我的问题与文本有关,而不是图像。
如何让CComboBoxEx 强制它显示更新后的文本值?
【问题讨论】:
标签: mfc comboboxex