WinForm Review [2] ComboBox control

Source: Internet
Author: User

ComboBox Important attribute: "DropDownStyle" Gets or sets the value of the specified combo box style.

The following is still a small program to review:

The code is as follows:

usingSystem;usingSystem.Windows.Forms;namespaceDate Selector { Public Partial classForm1:form { PublicForm1 () {InitializeComponent (); }        //when the program loads, add the year        Private voidForm1_Load (Objectsender, EventArgs e) {            //get the current year            intYear =DateTime.Now.Year; //Add year             for(inti = year; I >=1949; i--) {CMBYEAR.ITEMS.ADD (i+"years"); }        }        //the month is loaded when a change occurs        Private voidCmbyear_selectedindexchanged (Objectsender, EventArgs e) {            //before adding, you should clean upcmbMonth.Items.Clear (); //Add             for(inti =1; I <= A; i++) {CMBMONTH.ITEMS.ADD (i+"Month"); }        }        //when the month changes, load the day        Private voidCmbmonth_selectedindexchanged (Objectsender, EventArgs e)            {cmbDay.Items.Clear (); //get year, month            stringStryear = CmbYear.SelectedItem.ToString (). Split (New Char[] {'years'}, Stringsplitoptions.removeemptyentries) [0]; stringStrmonth = CmbMonth.SelectedItem.ToString (). Split (New Char[] {'Month'}, Stringsplitoptions.removeemptyentries) [0]; //convert to integral type            intYear =Convert.ToInt32 (stryear); intmonth =Convert.ToInt32 (Strmonth); //declaring a variable to represent the number of days            intDays =0; Switch(month) { Case 1:                 Case 3:                 Case 5:                 Case 7:                 Case 8:                 Case Ten:                 Case  A: Days= to;  Break;  Case 2:                    if(Datetime.isleapyear (year))//Judging Leap years{ days= in; }                    Else{ days= -; }                     Break; default: Days= -;  Break; }             for(inti =1; I <= days; i++) {CMBDAY.ITEMS.ADD (i+"Day"); }        }    }}

Source Code Link: http://pan.baidu.com/s/1pL9eTsf Password: Wvts

WinForm Review [2] ComboBox control

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.