标题:这个程序错哪里,为什么comboBox1里只有29项
取消只看楼主
别忘了当初
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2019-7-24
结帖率:100%
 问题点数:0 回复次数:0 
这个程序错哪里,为什么comboBox1里只有29项
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 选择日期02275
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            MessageBox.Show("今天是"+comboBox3.Text+"年"+comboBox2.Text+"月"+comboBox1.Text+"日");
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            int i,a,b;

            for (i = 1000; i <= 2050; i++)
            {
                comboBox3.Items.Add(i);
            }
            for (a = 1; a <=12; a++)
            {
                comboBox2.Items.Add(a);
            }
            switch (a)
            {
                case 1:
                case 3:
                case 5:
                case 7:
                case 8:
                case 10:
                case 12:
                    for (b = 0; b <= 31; b++)
                    {
                            comboBox1.Items.Add(b);
                    }
                    break;
                case 4:
                case 6:
                case 9:
                case 11:
                   for (b = 0; b <= 30; b++)
                   {
                        comboBox1.Items.Add(b);
                   }
                   break;
                default:
                case 2:
                    if (i % 4 == 0)
                    {
                        for (b = 0; b <= 28; b++)
                        {
                            comboBox1.Items.Add(b);
                        }
                    }
                    else
                    {
                        for (b = 0; b <= 29; b++)
                        {
                            comboBox1.Items.Add(b);
                        }
                    }

                    break;
            }
        }
    }
}
搜索更多相关主题的帖子: case Add using for System 
2019-09-04 12:03



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-496682-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014587 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved