C # programming introduction, application of controls (textBox, checkBox, listBox, listView, etc.) in C #

Source: Internet
Author: User

Open Visual Stdio for programming 1. application of the textBox Control: write code for the logon window: private void button#click (object sender, EventArgs e) {if (textBox2.Text = "123456" | textBox1.Text = "zhangsan ") {MessageBox. show ("Login successful");} else {MessageBox. show ("check whether the name and password are correct") ;}} 2. the checkBox (check box) control is applied. After the code for completing this graph is added to the show hobbies button code: private void button#click (object sender, EventArgs e) {// Add the Code if (textBox1.Text = "") {MessageBox in the show hobbies button event. show (this, "enter your name", "Message", MessageBoxButtons. OK, MessageBoxIcon. information);} else {if (checkBox1.Checked = true & checkBox2.Checked = true) textBox2.Text = textBox1.Text + "like" + checkBox1.Text + "and" + checkBox2.Text; else if (checkBox1.Checked = true & checkBox2.Checked = false) textBox2.Text = textBox1.Text + "like" + checkBox1.Text; else if (checkBox1.Checked = false & checkBox2.Checked = true) textBox2.Text = textBox1.Text + "like" + checkBox2.Text; else if (checkBox1.Checked = false & checkBox2.Checked = false) textBox2.Text = "" ;}} 3. the application of the listView control pulls a listView control and sets the attribute: View attribute is the result of opening Columns to add data items to the listView control in DeTails, add the event processing function static int itemNumber = 0 for the Add/delete button, respectively. //// the variable private void button#click (object sender, EventArgs e) is defined by the Constitution) {// construct the String array of the sub-entries of the entry String [] subItem = new String [] {textBox1.Text, textBox2.Text, textBox2.Text}; // Insert a new entry listView1.Items. add (new ListViewItem (subItem); listView1.Items [itemNumber]. imageIndex = 0; itemNumber ++;} private void button2_Click (object sender, EventArgs e) {for (int I = listView1.SelectedItems. count-1; I> = 0; I --) {// obtain ListViewItem li = listView1.SelectedItems [I]; // Delete this entry listView1.Items. remove (li); itemNumber --;}}

Related Article

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.