Test4_1
private void numericUpDown1_ValueChanged(object sender, EventArgs e) { trackBar1.Value = (int)numericUpDown1.Value; } private void trackBar1_Scroll(object sender, EventArgs e) { numericUpDown1.Value = trackBar1.Value; } }
Test4_2
private void hScrollBar2_Scroll(object sender, ScrollEventArgs e) { this.BackColor = Color.FromArgb(hScrollBar1.Value, hScrollBar2.Value, hScrollBar3.Value); } private void hScrollBar3_Scroll(object sender, ScrollEventArgs e) { this.BackColor = Color.FromArgb(hScrollBar1.Value, hScrollBar2.Value, hScrollBar3.Value); }
//备注:在每个滚动条的hScrollBar2_Scroll里面都放上this.BackColor = Color.FromArgb(hScrollBar1.Value, hScrollBar2.Value, hScrollBar3.Value);
2,3,4,5 的题都相似。
Test4_6
private void trackBar2_Scroll(object sender, EventArgs e) { progressBar1.Value = trackBar2.Value; this.Opacity = 0.5 + (double)trackBar2.Value / 100;//设置透明状态 }
Test4_7
private void radioButton2_CheckedChanged(object sender, EventArgs e) { if (radioButton1.Checked == true) comboBox1.SelectedIndex =1; } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { switch (comboBox1.SelectedIndex) { case 0:radioButton1.Checked = true;break; case 1:radioButton2.Checked = true;break; case 2:radioButton3.Checked = true;break; } } private void radioButton1_CheckedChanged(object sender, EventArgs e) { if (radioButton1.Checked == true) comboBox1.SelectedIndex = 0; } private void radioButton3_CheckedChanged(object sender, EventArgs e) { if (radioButton1.Checked == true) comboBox1.SelectedIndex = 2; }
7,8相似
Test4_9
private void checkBox1_CheckedChanged(object sender, EventArgs e) { if (checkBox1.Checked == true) listBox1.Items.Add("English"); else listBox1.Items.Remove("English"); } //checkBox2,checkBox3和此相似
Test4_10
private void domainUpDown1_SelectedItemChanged(object sender, EventArgs e) { // IBindingListView.Value = (int)numericUpDown1.Value; listBox2.SelectedIndex = domainUpDown1.SelectedIndex; } private void listBox2_SelectedIndexChanged(object sender, EventArgs e) { domainUpDown1.SelectedIndex = listBox2.SelectedIndex; }
Test4_11
Test4-12
private void checkBox1_CheckedChanged(object sender, EventArgs e) { if (checkBox1.Checked == true) { monthCalendar1.ShowToday = true; } else monthCalendar1.ShowToday = false; } //选中checkBox2,3时,代码相似
Test4_13
private void timer1_Tick(object sender, EventArgs e) { { if (this.progressBar1.Value == this.progressBar1.Maximum) { this.progressBar1.Value = this.progressBar1.Minimum; } else this.progressBar1.Value += 5; } if (this.progressBar2.Value == this.progressBar2.Maximum) { this.progressBar2.Value = this.progressBar2.Minimum; } else this.progressBar2.Value += 20; }//Timer的Enabled 为TURE
Test4_14
Test4_15
private void button1_Click(object sender, EventArgs e) { // if(button1.Click==true) this.timer1.Start(); this.button1.Enabled = false; this.button2.Enabled = true; }//button2相反的设定
第16题基本相似,略过
Test4_17
18题与19题相似
Test4_19
private void timer1_Tick(object sender, EventArgs e) { this.dateTimePicker1.Value = this.dateTimePicker1.Value.AddSeconds(1); }//使计时器的时间比当前时间快1秒 private void button1_Click(object sender, EventArgs e) { if (this.dateTimePicker1.Enabled == false) this.dateTimePicker1.Enabled = true;//使计时器控件为打开 this.button1.Enabled = false;//使button1不能被选中 this.timer1.Start();//使计时器为打开状态 this.button2.Enabled = true;//使button2能被选中 } //butoon2的代码与button1相反
Test4_20
private void timer1_Tick(object sender, EventArgs e) { monthCalendar1.SelectionStart = monthCalendar1.SelectionStart.AddDays(1); }//只有添加日期的一点不一样,其余跟19题一样