?
Solved

MS VISUAL C++ HELP

Posted on 2003-03-20
5
Medium Priority
?
259 Views
Last Modified: 2010-04-01
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
Comment
Question by:ChrisWUK
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 237 total points
ID: 8173680
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
 

Author Comment

by:ChrisWUK
ID: 8174592
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
 

Author Comment

by:ChrisWUK
ID: 8192209
can any1 explain how to do this in simple terms/steps - thanks !!
0
 

Author Comment

by:ChrisWUK
ID: 8192231
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
 

Author Comment

by:ChrisWUK
ID: 8194451
Its OK - ive worked it around another way - thanks for your input Alex - i will accept ur comment as an answer  :)
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question