for (int xx = 0; xx < piCount; xx++)
{
comboBox1.Items.Add(xx);
}
Run Code Online (Sandbox Code Playgroud)
piCount是int.它的值是8.如果我从0开始我将在comboBox 01234567中看到但我想看到12345678
只需改变你的循环:
for (int xx = 1; xx <= piCount; xx++)
{
comboBox1.Items.Add(xx);
}
Run Code Online (Sandbox Code Playgroud)
注意如何将上限比较更改<为<=.
您还可以保持循环并在正文中添加1:
for (int xx = 0; xx < piCount; xx++)
{
comboBox1.Items.Add(xx + 1);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
565 次 |
| 最近记录: |