Windows Foundation controls use

Source: Internet
Author: User

Button buttons

TextBox text Box Event TextChanged

Label label

CheckBox check box

private void textBox1_TextChanged (object sender, EventArgs e)
{
if (TextBox1.Text = = "123") TextBox2.Text = "Xiao Ming";
else TextBox2.Text = ("Password error");
}

Password Display Name

check box in the code

private void Checkbox1_checkedchanged (object sender, EventArgs e)
{
if (checkbox1.checked = = True && checkbox2.checked==true)
TextBox3.Text = "I like" + Checkbox1.text + "and" + checkbox2.text;
else if (checkbox1.checked = = True && checkbox2.checked = = False)
TextBox3.Text = "I like" + Checkbox1.text;
else if (checkbox1.checked = = True && checkbox2.checked = = False)
TextBox3.Text = "I like" + Checkbox2.text;
else if (checkbox1.checked = = True && checkbox2.checked = = False)
TextBox3.Text = "";
}

private void Checkbox2_checkedchanged (object sender, EventArgs e)
{
if (checkbox1.checked = = True && checkbox2.checked==true)
TextBox3.Text = "I like" + Checkbox1.text + "and" + checkbox2.text;
else if (checkbox1.checked = = True && checkbox2.checked = = False)
TextBox3.Text = "I like" + Checkbox1.text;
else if (checkbox1.checked = = True && checkbox2.checked = = False)
TextBox3.Text = "I like" + Checkbox2.text;
else if (checkbox1.checked = = True && checkbox2.checked = = False)
TextBox3.Text = "";
}

Add the RadioButton radio button code using the following:

private void Radiobutton1_checkedchanged (object sender, EventArgs e)
{
if (radiobutton1.checked = = True)
Textbox4.text = "I am very" +radiobutton1.text;
{

}
}

private void Radiobutton2_checkedchanged (object sender, EventArgs e)
{
if (radiobutton2.checked = = True)
Textbox4.text = "I am very" + radiobutton2.text;
}
}

ListBox list Box

Find Items Property Point Open Collection

Display the String Collection Editor

Writing code

private void listBox1_SelectedIndexChanged (object sender, EventArgs e)
{
Textbox5.text = "You like the first" + listBox1.SelectedIndex.ToString () + "kind of color:" +LISTBOX1.TEXT;
}
}

Combo Box combobox

The DropDownStyle property controls the appearance and functionality.

There are simple, dropdown,dropdownlist 3 options

Common events

Leave occurs when the control is no longer the active control of the form.

SelectedIndexChanged changing the Selectedindew property of a control occurs

First, enter the items collection to write the string

Then the code runs

private void ComboBox1_SelectedIndexChanged (object sender, EventArgs e)
{
if (Combobox1.selectedindex = = 0) Textbox6.text = "Aries";
else if (Combobox1.selectedindex = = 1) textbox6.text = "Taurus";
else if (Combobox1.selectedindex = = 2) Textbox6.text = "Gemini";
else if (Combobox1.selectedindex = = 3) Textbox6.text = "Crab seat";
else if (Combobox1.selectedindex = = 4) Textbox6.text = "Lion";
else if (Combobox1.selectedindex = = 5) Textbox6.text = "virgin";
else if (Combobox1.selectedindex = = 6) Textbox6.text = "balance";
else if (Combobox1.selectedindex = = 7) Textbox6.text = "Scorpio";
else if (Combobox1.selectedindex = = 8) Textbox6.text = "Shooter";
else if (Combobox1.selectedindex = = 9) Textbox6.text = "Magic scorpion";
else if (Combobox1.selectedindex ==10)
Textbox6.text = "water bottle";
else if (combobox1.selectedindex ==11) textbox6.text = "Pisces";
}
}
}

ToolTip tooltip

Windows Foundation controls use

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.