none
Facing problem in adding string to Combo box in sorted list format.

    Question

  • Hi,

    I am working on C and win32 based application in which i am facing a problem while

    adding a date (which is in string format) to a combo box using CB_ADDSTRING. The dates get added to the combo box but not in sorted form.

    I am using following syntax:-

    SendDlgItemMessage(<Handle>,< Combobox ID>, CB_ADDSTRING,(WPARAM)0, (DWORD)(LPSTR)TmpDate);

    I want date to be displayed in sorted format, as far as my knowledge in CB_ADDSTRING; If the combo box does not have the CBS_SORT style, the string is added to the end of the list. Otherwise, the string is inserted into the list, and the list is sorted.

    In my case list is not getting sorted.

    Kindly suggest how this can be achieved.

    Thanks in advance.

    Regards

    Reo

    Monday, January 13, 2014 5:57 AM

Answers

  • Hi Reo,

    Welcome to MSDN forum.

    >>I am working on C and win32 based application in which i am facing a problem while adding a date (which is in string format) to a combo box using CB_ADDSTRING. The dates get added to the combo box but not in sorted form.

    Could you please clarify this problem with screenshots or sample code?

    How did you design the combo box style?

    Was this sorted format by number sequences or alphabet order?

    In addition, you can check the suggestions in the following topics:

    How to set ccombobox property from code?

    Best Regards,

    Jane.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Tuesday, January 14, 2014 5:17 AM
  • The dates will be sorted if they are in a format such as 2014-01-14. Otherwise you have to handle the WM_COMPAREITEM message. What is the format of your dates?

    Tuesday, January 14, 2014 6:07 AM

All replies

  • Hi Reo,

    Welcome to MSDN forum.

    >>I am working on C and win32 based application in which i am facing a problem while adding a date (which is in string format) to a combo box using CB_ADDSTRING. The dates get added to the combo box but not in sorted form.

    Could you please clarify this problem with screenshots or sample code?

    How did you design the combo box style?

    Was this sorted format by number sequences or alphabet order?

    In addition, you can check the suggestions in the following topics:

    How to set ccombobox property from code?

    Best Regards,

    Jane.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Tuesday, January 14, 2014 5:17 AM
  • The dates will be sorted if they are in a format such as 2014-01-14. Otherwise you have to handle the WM_COMPAREITEM message. What is the format of your dates?

    Tuesday, January 14, 2014 6:07 AM