CComboBox

This is a discussion on CComboBox within the Windows Programming forums, part of the Platform Specific Boards category; Hello- does anyone know how to retreive the Edit box's text from a dropdown combobox? I can get the current ...

  1. #1
    Anal comment spacer DominicTrix's Avatar
    Join Date
    Apr 2002
    Posts
    120

    Unhappy CComboBox

    Hello- does anyone know how to retreive the Edit box's text from a dropdown combobox?

    I can get the current selection etc. but this is useless if there is no selection, i.e. when the user is entering their own data. Nowhere does there appear to be a function to get the text from the editbox

    I guess it's there and that it's staring me in the face but could anyone point it out?

    (I'm using MFC.)

    Thanks in advance

    dt

    /////////////////////////////////////////////////
    UPDATE
    /////////////////////////////////////////////////

    Sorry, I'm thick,
    Code:
    CWnd::GetWindowText(CString&)
    That's the one.
    Last edited by DominicTrix; 09-03-2003 at 12:00 PM.
    "The most important thing about acting is honesty. If you can fake that you've got it made" - George Burns

  2. #2
    Master of the Universe! velius's Avatar
    Join Date
    Sep 2003
    Posts
    219

    CComboBox

    You use CComboBox::GetWindowText(CString&);
    If it is in a dialog you need to use GetDlgItem(IDC_whatever)
    You also need a CString variable to store the text or a C-string (char array). Note: GetDlgItem() does not need to work with a Dialog, the name is miss-leading. It will get the Item by ID even if it is in a window of a MDI or SDI style program.
    Code:
    // pretend your id your Combo Box as IDC_COMBOBOX
    CComboBox* pCB = (CComboBox*)GetDlgItem(IDC_COMBOBOX);
    CString str;
    pCB->GetWindowText(str);
    While you're breakin' down my back n'
    I been rackin' out my brain
    It don't matter how we make it
    'Cause it always ends the same
    You can push it for more mileage
    But your flaps r' wearin' thin
    And I could sleep on it 'til mornin'
    But this nightmare never ends
    Don't forget to call my lawyers
    With ridiculous demands
    An you can take the pity so far
    But it's more than I can stand
    'Cause this couchtrip's gettin' older
    Tell me how long has it been
    'Cause 5 years is forever
    An you haven't grown up yet
    -- You Could Be Mine - Guns N' Roses

  3. #3
    Anal comment spacer DominicTrix's Avatar
    Join Date
    Apr 2002
    Posts
    120
    cheers velius - I'd actually already worked it out - I guess my update wasnt very clear, sorry.

    Thanks for your time anyways,

    dt
    "The most important thing about acting is honesty. If you can fake that you've got it made" - George Burns

  4. #4
    Master of the Universe! velius's Avatar
    Join Date
    Sep 2003
    Posts
    219
    Don't mention it. I love answering questions. Yeah now that I read it in the context of you changed it to say you found it, I can see that now.
    While you're breakin' down my back n'
    I been rackin' out my brain
    It don't matter how we make it
    'Cause it always ends the same
    You can push it for more mileage
    But your flaps r' wearin' thin
    And I could sleep on it 'til mornin'
    But this nightmare never ends
    Don't forget to call my lawyers
    With ridiculous demands
    An you can take the pity so far
    But it's more than I can stand
    'Cause this couchtrip's gettin' older
    Tell me how long has it been
    'Cause 5 years is forever
    An you haven't grown up yet
    -- You Could Be Mine - Guns N' Roses

  5. #5
    Anal comment spacer DominicTrix's Avatar
    Join Date
    Apr 2002
    Posts
    120
    lol - cheers
    "The most important thing about acting is honesty. If you can fake that you've got it made" - George Burns

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. CComboBox scrolling
    By smash84 in forum Windows Programming
    Replies: 2
    Last Post: 08-15-2006, 11:09 AM
  2. CComboBox issue
    By axr0284 in forum Windows Programming
    Replies: 0
    Last Post: 03-11-2006, 01:33 PM
  3. From CComboBox to CSpinButtonCtrl (Help Help)
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 10-19-2005, 02:29 AM
  4. SetItemData problem
    By Yelrig in forum Windows Programming
    Replies: 0
    Last Post: 10-20-2003, 11:39 AM
  5. Visual C++ Problem, CComboBox
    By UnclePunker in forum C++ Programming
    Replies: 5
    Last Post: 09-17-2003, 10:11 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21