我用2個CStringList對象編碼。每個人都有自己的數據,例如一個人有姓名和其他的phoneno,並且兩者都是同步的,即如果有phoneno,就有名字,反之亦然。MFC中的CStringList
現在,我有2個組合框,其中我顯示名稱和各自的phonenos。名稱組合框是排序的,因此兩者之間的同步進行折騰。因此,對於分選我做了以下內容:
int aComboElementNo = myNameComboBox.GetCount();
if(aComboElementNo >= 1)
{
for(int aIndex = 0; aIndex < aComboElementNo; aIndex++)
{
CString aTempStr;
// Getting the string in the combobox
myNameComboBox.GetLBText(aIndex, aTempStr);
// Getting the position where the name is present in the list
POSITION aPos = aNameList.Find(aTempStr);
// setting the appropriate phoneno in the 2nd combobox
myPhoneComboBox.AddString(aPhoneList.GetAt(aPos));
}
}
當我執行此我得到了在myPhoneComboBox的名字,而不是phonenos。
現在我有2個QNS:
怎麼來的我得到禮物的名稱列表的名稱,當我訪問PHONELIST?是不是一個違反,因爲我能夠使用其他變量訪問其他變量數據。
如何排序第二個列表。
這兩個列表是CStringList對象。 – Raghu 2008-12-18 05:50:51
我認爲你的問題缺乏太多的情境化。你用什麼方法來做到這一點?你想做什麼? – sergiol 2014-06-23 23:55:33