| |

VerySource

 Forgot password?
 Register
Search
View: 1209|Reply: 5

Ask how to define a structure in MFC, ask to select one part of the structure, and display another part

[Copy link]

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-21 00:00:01
| Show all posts |Read mode
Ask how to define a structure in MFC, ask to select one part of the structure, and display another part
I define the structure like this:
struct CStruct
{
CString Name;
CString XueFen;
};

BOOL CMy2Dlg :: OnInitDialog ()
{
CStruct str [4] = {"Advanced Mathematics", "6", "data", "6", "java", "7", "English",
"4"};
int n;
for (int i = 0; i <= 4; i ++)
{
n = m_select.AddString (str [i] .Name);
m_select.SetItemData (n, i); // Realistic drop-down list
}
m_select.SetCurSel (0);
return TRUE; // return TRUE unless you set the focus to a control
}

The definition is wrong here, please advise!
There is also how to select a subject in the drop-down menu to display the credits of this subject
If "JAVA" is selected, the credits will be displayed in the edit box next to "6"

Please advise
Reply

Use magic Report

0

Threads

20

Posts

21.00

Credits

Newbie

Rank: 1

Credits
21.00

 China

Post time: 2020-1-30 15:09:01
| Show all posts
CStruct str [4] = {{"Advanced Mathematics", "6"}, {"data", "6"}, {"java", "7"}, {"English", "4"}};
Should be defined like this
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-2-1 23:27:01
| Show all posts
No, I still report an error!
Reply

Use magic Report

0

Threads

20

Posts

21.00

Credits

Newbie

Rank: 1

Credits
21.00

 China

Post time: 2020-2-2 15:18:01
| Show all posts
for (int i = 0; i <= 4; i ++) // Change to: for (int i = 0; i <4; i ++)
{
n = m_select.AddString (str [i] .Name);
m_select.SetItemData (n, i); // Realistic drop-down list
}
Reply

Use magic Report

0

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-2-17 12:15:02
| Show all posts
Ibid. The concept of arrays is not very clear. Think about it carefully. 0 1 2 3 is 4. Where did 4 come from !!!!!!!!!!!!
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-7-3 12:30:01
| Show all posts
CStruct str[4]={"Advanced Mathematics","6","data","6","java","7","English","4"};

How to initialize this str[4] structure array?
Which expert please click! !
Thank you!
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list