1.数组里有一些值 比如中国人 美国人 日本人 英国人,这里不知道顺序的
2.现在要加入到combobox里 我想把 中国人排在第一位  然后英国人 美国人 日本人。
问题是这里怎么指定顺序啊,insertstring 可以指定索引,但是这里数组里的顺序不定的,说不定第一个就是日本人也或许是英国人 那这样先insertstring 2,3 也没用了~~有什么办法的啊

解决方案 »

  1.   

    ComboBox属性设置中有个sort选项,若为True则按首字母顺序添加,为False则每次添加到列表最后
      

  2.   

    // CMyComboBox message handlers
    int CMyComboBox::CompareItem(LPCOMPAREITEMSTRUCT lpCompareItemStruct) 
    {
    // TODO: Add your code to determine the sorting order of the specified items
    // For programm comes here,need to cancel "cbs_hasstrings" property.
    // return -1 = item 1 sorts before item 2
    // return 0 = item 1 and item 2 sort the same
    // return 1 = item 1 sorts after item 2
    //typedef struct tagCOMPAREITEMSTRUCT {
    //    UINT   CtlType;
    //    UINT   CtlID;
    //    HWND   hwndItem;
    //    UINT   itemID1;
    //    DWORD  itemData1;without "cbs_hasstrings" the added string point will put here ! 
    //    UINT   itemID2;always ==-1 microsoft give me a 0xFFFFFFFF ???
    //    DWORD  itemData2;
    //} COMPAREITEMSTRUCT;
    if(m_bReverseSort)
    {
    return (strcmp((LPTSTR)lpCompareItemStruct->itemData2,
    (LPTSTR)lpCompareItemStruct->itemData1));
    }
    else
    {
    return (strcmp((LPTSTR)lpCompareItemStruct->itemData1,  // row 2 row1
    (LPTSTR)lpCompareItemStruct->itemData2));// row 0 row2
    }
    }