Need MFC Combo Box Help [modified]
-
I've got an MFC dialog box with a combo box and several text boxes. I have to know what item in the combo box is selected in order to display the right content in the text boxes. Right now I have it set up so that when the user clicks a button it executes this segment: CurrentSelection = ComboBoxPtr->GetCurSel(); CurrentContact = m_pMainWnd->OperationsClass.PhoneBookClass.ReturnContact(CurrentSelection); //update text boxes based on name combo box selection UpdateContactTextBoxes(CurrentSelection); How can is I set it up so that it will detect when the user makes a change in the combo box, gets the current selection, and automatically executes UpdateContactTextBoxes(CurrentSelection), all without using a button? I saw a tutorial on how to do it with a wizard, but can anyone tell me how to do it with straight MFC code? I hate wizards.
-
I've got an MFC dialog box with a combo box and several text boxes. I have to know what item in the combo box is selected in order to display the right content in the text boxes. Right now I have it set up so that when the user clicks a button it executes this segment: CurrentSelection = ComboBoxPtr->GetCurSel(); CurrentContact = m_pMainWnd->OperationsClass.PhoneBookClass.ReturnContact(CurrentSelection); //update text boxes based on name combo box selection UpdateContactTextBoxes(CurrentSelection); How can is I set it up so that it will detect when the user makes a change in the combo box, gets the current selection, and automatically executes UpdateContactTextBoxes(CurrentSelection), all without using a button? I saw a tutorial on how to do it with a wizard, but can anyone tell me how to do it with straight MFC code? I hate wizards.
Use events associated with the combo box.
We Believe in Excellence www.aqueelmirza.cjb.net
-
I've got an MFC dialog box with a combo box and several text boxes. I have to know what item in the combo box is selected in order to display the right content in the text boxes. Right now I have it set up so that when the user clicks a button it executes this segment: CurrentSelection = ComboBoxPtr->GetCurSel(); CurrentContact = m_pMainWnd->OperationsClass.PhoneBookClass.ReturnContact(CurrentSelection); //update text boxes based on name combo box selection UpdateContactTextBoxes(CurrentSelection); How can is I set it up so that it will detect when the user makes a change in the combo box, gets the current selection, and automatically executes UpdateContactTextBoxes(CurrentSelection), all without using a button? I saw a tutorial on how to do it with a wizard, but can anyone tell me how to do it with straight MFC code? I hate wizards.
Just add a handler to CBN_SELCHANGE message and put your code there..
-
I've got an MFC dialog box with a combo box and several text boxes. I have to know what item in the combo box is selected in order to display the right content in the text boxes. Right now I have it set up so that when the user clicks a button it executes this segment: CurrentSelection = ComboBoxPtr->GetCurSel(); CurrentContact = m_pMainWnd->OperationsClass.PhoneBookClass.ReturnContact(CurrentSelection); //update text boxes based on name combo box selection UpdateContactTextBoxes(CurrentSelection); How can is I set it up so that it will detect when the user makes a change in the combo box, gets the current selection, and automatically executes UpdateContactTextBoxes(CurrentSelection), all without using a button? I saw a tutorial on how to do it with a wizard, but can anyone tell me how to do it with straight MFC code? I hate wizards.
CoffeeAddict19 wrote:
How can is I set it up so that it will detect when the user makes a change in the combo box,
Use
CBN_SELENDOK
.
Nibu thomas A Developer Programming tips[^] My site[^]
-
CoffeeAddict19 wrote:
How can is I set it up so that it will detect when the user makes a change in the combo box,
Use
CBN_SELENDOK
.
Nibu thomas A Developer Programming tips[^] My site[^]
Thanks for your help. I got it working now. :)