locked
combo box RRS feed

  • Question

  • hi all,
    could anyone help in adding string sto a cmbo box. i am able to add only one string in that?


    Thanks
    Ezhilmani.R
    Saturday, July 18, 2009 8:57 AM

Answers

  • Hello,

    for(int i = 0; i < numofStrings; i++)
       SendMessage(hComboBox, CB_INSERTSTRING, i, (LPARAM)string[i]);

    Thanks
    Arpit Pradhan

    WinCE CODER (If you think my solution help you in some sense do mark my Reply as Answer)
    • Edited by NEO131 Saturday, July 18, 2009 10:04 AM
    • Marked as answer by MANI 007 Saturday, July 18, 2009 11:35 AM
    Saturday, July 18, 2009 9:36 AM

All replies

  • Hello,

    for(int i = 0; i < numofStrings; i++)
       SendMessage(hComboBox, CB_INSERTSTRING, i, (LPARAM)string[i]);

    Thanks
    Arpit Pradhan

    WinCE CODER (If you think my solution help you in some sense do mark my Reply as Answer)
    • Edited by NEO131 Saturday, July 18, 2009 10:04 AM
    • Marked as answer by MANI 007 Saturday, July 18, 2009 11:35 AM
    Saturday, July 18, 2009 9:36 AM
  • Hi,

    An example in C# :-

                for (int i = 0; i < numofStrings; i++)
                {
                    this.comboBox1.Items.Add("String 1");
                }
    Hope this helps.

    Paul Diston
    http://www.smartmobiledevice.co.uk/
    Saturday, July 18, 2009 10:00 AM
  • hi arpit,
                Thanks for ur interest..Ihav found another way of setting items... it is like this.

    SendDlgItemMessage( g_hWndDlg1,IDC_COUNTRY, CB_INSERTSTRING,0, (LPARAM)TEXT(

    "INDIA"));

    this i hav done after creating dialog box..this works fine...
    But I am facing some problems when i do like this..

    SendMessage(g_hWndDlg1, CB_INSERTSTRING, index, (LPARAM)(LPCSTR)"US");

    in this ,i have to collect in the switch case of Dialogproc function for the messag CB_INSERTSTRING and in that i am using

    SetDlgItemText( g_hWndDlg1, IDC_COUNTRY,(LPCTSTR) lParam );

     

     

    but lparam has some junk values instead of the strings which ihad sent through SendMessage fn.


    Thanks

    Ezhil 

    Saturday, July 18, 2009 11:41 AM
  • hi paul,
                I am using C language in Visualstudio.. hope this is somewhat diff from C#...

                Anyway thanks for ur interest




    Saturday, July 18, 2009 11:46 AM
  • Hi,

    Just a little tip when posting a question, it is useful to people trying to answer questions to know which language you are interested in.

    Thanks

    Paul Diston

    http://www.smartmobiledevice.co.uk/
    Saturday, July 18, 2009 9:30 PM