วันอังคารที่ 8 พฤศจิกายน พ.ศ. 2554

งาน อ. ธนากร

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace NOt2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void radioButton1_CheckedChanged(object sender, EventArgs e)
{

}

private void radioButton1_Click(object sender, EventArgs e)
{
MessageBox.Show("คุณเลือกเพศชาย");
}

private void radioButton2_Click(object sender, EventArgs e)
{
MessageBox.Show("คุณเลือกเพศหญิง");
}

private void Form1_Load(object sender, EventArgs e)
{
radioButton1.Checked = false;
radioButton2.Checked = false;
}

private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
showColor();
//panel1.BackColor = Color.Red;
}

private void checkBox2_CheckedChanged(object sender, EventArgs e)
{
showColor();
//panel1.BackColor = Color.Green;
}

private void checkBox3_CheckedChanged(object sender, EventArgs e)
{
showColor();
//panel1.BackColor = Color.Blue;
}

private void showColor()
{
if ((checkBox1.Checked) && (checkBox2.Checked) && (checkBox3.Checked))
{
panel1.BackColor = Color.White;
}
else if ((checkBox1.Checked) && (checkBox2.Checked))
{
panel1.BackColor = Color.Yellow;
}
else if ((checkBox1.Checked) && (checkBox3.Checked))
{
panel1.BackColor = Color.Magenta;
}
else if ((checkBox2.Checked) && (checkBox3.Checked))
{
panel1.BackColor = Color.Cyan;
}

else if (checkBox1.Checked)
{
panel1.BackColor = Color.Red;
}
else if (checkBox2.Checked)
{
panel1.BackColor = Color.Green;
}
else if (checkBox3.Checked)
{
panel1.BackColor = Color.Blue;
}

}
}

}

ไม่มีความคิดเห็น:

แสดงความคิดเห็น