| |

VerySource

 Forgot password?
 Register
Search
View: 1017|Reply: 6

Question about the drop-down box

[Copy link]

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-2-7 14:30:01
| Show all posts |Read mode
// show month // show the month
    for (int b = 1; b <= 12; b ++)
    {
CString st;
st.Format ("% d", b);
          m_yue.AddString (st);
    }

    CString s;
    s.Format ("% d", m);
    int t = m_yue.SelectString (0, s);
    m_yue.SetCurSel (t); // Set the default month to the current month

When the month is 10-12, there is no problem with the default display, but there are problems from January to September. This month is January, but October is selected by default. The debugging knows that there is a problem in the int t = m_yue.SelectString (0, s). The result of s is correct, which is 1, but t does not get 0 after running. , But 9.

I also have a drop-down box. On the default date, the writing method is the same, but there is no such strange phenomenon.

I don't know what the reason is, I hope everyone helps, thank you!
Reply

Use magic Report

0

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-4-2 13:45:02
| Show all posts
int t = m_yue.SelectString (0, s);
搂 The master assigns data of type string to integer. Take a look
Reply

Use magic Report

0

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-4-2 17:15:01
| Show all posts
Sorry. I read it wrong. I just said wrong
Reply

Use magic Report

0

Threads

9

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-4-2 22:45:01
| Show all posts
Cancel the Sort property of CComboBox
Or use the following values: "01", "02", .... "09", "10", "11", "12";
String comparison "2", "3" .... "9"〉 "10", "11", "12"
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-4-3 17:30:02
| Show all posts
No sort is used, the default is no sort. I use the combo box control.


The date control will not have this problem. For example, today is the 4th, and it can be the default 4th. code show as below:
CString s2;
s2.Format ("% d", d);
int t2 = m_ri.SelectString (0, s2); // Get the serial number of the current date in the list
m_ri.SetCurSel (t2);
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-4-6 01:45:01
| Show all posts
Just tested again just now, it will only make mistakes in January, and will not make mistakes in February-December. This is also the case in the date drop-down box. If it is number 1, the default is also 10. All other conditions are displayed correctly.

I really don't understand.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-4-13 09:30:01
| Show all posts
It is estimated that it is s2.Format ("% d", d); There is a problem with this sentence. Maybe you have set the format, so you cannot find this 1, so there is a problem
I think it should be changed to the form of s2.Format ("%-2d", d) ;.
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