• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 268
  • Last Modified:

MS VISUAL C++ HELP

I'm making a program that lets a user view an access database, and allows them to change the fields via a pop up dialog box. Ive nearly finished it apart from one more thing i am stuck on.
When the user clicks the edit button on the form, a dialog box appears which allows the user to edit them. The edit Dialog box contains 3 edit fields (which the user can change the First name, last name & registration number), 2 check boxes so the user can change the sex, and a dropdown COMBO box, where the user can change the course. I just need some help in changing the course?

In the combo box, there are 3 things the user can choose - Applied Electronics, Broadcast Technology & Applied Computer Technology. Once they have chosen the course and pressed ok, i need the form to update the Course field (which is an edit box), with the letters A, B or C, which correspond accordingly.

All Help Appreciated
0
ChrisWUK
Asked:
ChrisWUK
  • 4
1 Solution
 
AlexFMCommented:
Combo box should have Dropdown list style (set it in dialog template). Uncheck also Sorted style.

To fill combo (in OnInitDialog):

m_combo.AddString("Applied Electronics");
m_combo.AddString("Broadcast Technology ");
m_combo.AddString("Applied Computer Technology");

To set start value:

m_combo.SetCurSel(n);

where n = 0, 1 or 2 accroding to current Course value.

When dialog is closed (OK), keep current combo box selection in class member:

m_nSelection = m_combo.GetCurSel();

Fill Cource field according to m_nSelection value:
0 - A, 1 - B, 2 - C.

m_combo is CComboBox dialog member, add it using MFC Class Wizard.
0
 
ChrisWUKAuthor Commented:
i'm a little confused, can u explain a few things please?


To fill combo (in OnInitDialog):

m_combo.AddString("Applied Electronics");
m_combo.AddString("Broadcast Technology ");
m_combo.AddString("Applied Computer Technology");

I havent got anywhere called OnInitDialog. The Dialog starts when the user presses the edit button on the form, ive tried putting it in there, but it doesnt work.
0
 
ChrisWUKAuthor Commented:
can any1 explain how to do this in simple terms/steps - thanks !!
0
 
ChrisWUKAuthor Commented:
i have found the OnInintDialog - but i keep getting these errors

error C2228: left of '.SetCurSel' must have class/struct/union type

error C2228: left of '.AddString' must have class/struct/union type
0
 
ChrisWUKAuthor Commented:
Its OK - ive worked it around another way - thanks for your input Alex - i will accept ur comment as an answer  :)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now