using System; using System.Drawing; using System.Windows.Forms; namespace TEP { public partial class Form1 : Form { public Form1() { InitializeComponent(); checkBox1.Text = "TEP CheckBox1"; checkBox2.Text = "TEP CheckBox2"; checkBox3.Text = "TEP CheckBox3"; checkBox4.Text = "TEP CheckBox4"; checkBox5.Text = "TEP CheckBox5"; } } }In the above code, you have observed that we have used text property right after initializecomponent() method. Because we are setting checkbox text dynamically and it will only happen when we will declare this code in the initialization phase of a desktop application. In the following image, you can observe the output of above code.
using System; using System.Drawing; using System.Windows.Forms; namespace TEP { public partial class Form1 : Form { public Form1() { InitializeComponent(); checkBox1.Checked = true; checkBox2.Checked = true; checkBox3.Checked = true; } } }In the above code, we only marked check first three checkboxes. By this, you can mark check and uncheck the checkboxes by default. In the following image, you can observe the output of above code.
using System; using System.Drawing; using System.Windows.Forms; namespace TEP { public partial class Form1 : Form { public Form1() { InitializeComponent(); checkBox1.BackColor = Color.AliceBlue; checkBox2.BackColor = Color.Beige; checkBox3.BackColor = Color.BlueViolet; checkBox4.BackColor = Color.BurlyWood; checkBox5.BackColor = Color.DarkBlue; checkBox6.BackColor = Color.DarkOrange; checkBox7.BackColor = Color.DeepSkyBlue; checkBox8.BackColor = Color.Gainsboro; checkBox9.BackColor = Color.LawnGreen; checkBox10.BackColor = Color.LightSeaGreen; } } }There are ten checkboxes in the above code, each checkbox has a unique color. Color combination is the major part of designing phase. The client basically focused on the front end of the desktop app that's why coloring matters a lot. In the following image, you can be observed that what right color mean to the eye and whats the wrong color means to an eye, its the output of above code.
using System; using System.Drawing; using System.Windows.Forms; namespace TEP { public partial class Form1 : Form { public Form1() { InitializeComponent(); checkBox1.ForeColor = Color.AliceBlue; checkBox2.ForeColor = Color.Beige; checkBox3.ForeColor = Color.BlueViolet; checkBox4.ForeColor = Color.BurlyWood; checkBox5.ForeColor = Color.DarkBlue; checkBox6.ForeColor = Color.DarkOrange; checkBox7.ForeColor = Color.DeepSkyBlue; checkBox8.ForeColor = Color.Gainsboro; checkBox9.ForeColor = Color.LawnGreen; checkBox10.ForeColor = Color.LightSeaGreen; } } }In the above code, some colors are very light in shade and some are dark. We can't judge the color by their names. Because there are many colors to be used. If you want to select any color then you can to try all the color first. In the following image, you can observe the output of the above code. Some colors are the light that's why you can't clearly saw the output.
using System; using System.Drawing; using System.Windows.Forms; namespace TEP { public partial class Form1 : Form { public Form1() { InitializeComponent(); checkBox1.Font = new Font(Font.FontFamily, 5); checkBox2.Font = new Font(Font.FontFamily, 6); checkBox3.Font = new Font(Font.FontFamily, 7); checkBox4.Font = new Font(Font.FontFamily, 8); checkBox5.Font = new Font(Font.FontFamily, 9); checkBox6.Font = new Font(Font.FontFamily, 10); checkBox7.Font = new Font(Font.FontFamily, 11); checkBox8.Font = new Font(Font.FontFamily, 12); checkBox9.Font = new Font(Font.FontFamily, 13); checkBox10.Font = new Font(Font.FontFamily, 14); } } }We have used Font.FontFamily as the prototype and integer value as the size of the font. You can also change the font family by using the font constructor. In the following image, you can observe the output of above code. You will also observe that as much integer value is small the size gets decreased and as much the value is incremented the size get increased.
using System; using System.Drawing; using System.Windows.Forms; namespace TEP { public partial class Form1 : Form { public Form1() { InitializeComponent(); checkBox1.Font = new Font("Times New Roman", 11); checkBox2.Font = new Font("Century", 11); checkBox3.Font = new Font("Arial", 11); checkBox4.Font = new Font("Comic Sans MS", 11); checkBox5.Font = new Font("Copperplate Gothic Light", 11); checkBox6.Font = new Font("Georgia", 11); checkBox7.Font = new Font("Impact", 11); checkBox8.Font = new Font("Lucida Console", 11); } } }All the above font family names are the default fonts which are available in the windows. If you want to use the special kind of font then you have to install that first before use. You have also mentioned the size along with the font family name. In the following image, you can be observed the output of the above code, and what font effects on the desktop application.
using System; using System.Drawing; using System.Windows.Forms; namespace TEP { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { if (checkBox1.Checked == true) { MessageBox.Show(checkBox1.Text); } if (checkBox2.Checked == true) { MessageBox.Show(checkBox2.Text); } if (checkBox3.Checked == true) { MessageBox.Show(checkBox3.Text); } if (checkBox4.Checked == true) { MessageBox.Show(checkBox4.Text); } if (checkBox5.Checked == true) { MessageBox.Show(checkBox5.Text); } if (checkBox6.Checked == true) { MessageBox.Show(checkBox6.Text); } if (checkBox7.Checked == true) { MessageBox.Show(checkBox7.Text); } if (checkBox8.Checked == true) { MessageBox.Show(checkBox8.Text); } if (checkBox9.Checked == true) { MessageBox.Show(checkBox9.Text); } if (checkBox10.Checked == true) { MessageBox.Show(checkBox10.Text); } } } }You can observe the output of the above code in the following image. In which we have to click the button after the selection of checkbox3 and it returns the message box with its name.
using System; using System.Drawing; using System.Windows.Forms; namespace TEP { public partial class Form1 : Form { public Form1() { InitializeComponent(); checkBox1.Image = Image.FromFile("C:\\Users\\Jade\\Pictures\\brownImage.jpg"); } } }
using System; using System.Drawing; using System.Windows.Forms; namespace TEP { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { checkBox1.BackColor = Color.AliceBlue; } private void checkBox1_BackColorChanged(object sender, EventArgs e) { MessageBox.Show("BackColorChanged Executed!"); } } }We have used AliceBlue color for the background. You can use other colors too, there are varieties of colors are available. In the following image, you can observe the output of above code. We have executed just message box when the color changed, you can perform any kind of functionality.
using System; using System.Drawing; using System.Windows.Forms; namespace TEP { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void checkBox1_CheckedChanged(object sender, EventArgs e) { MessageBox.Show("CheckedChanged Executed!"); } } }You have to create a CheckedChange event for each of the C# CheckBox. We have just created for the first checkBox. In the following image, you can observe that we only mark checked the first checkbox and it returns the message popup.
using System; using System.Drawing; using System.Windows.Forms; namespace TEP { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void checkBox1_Click(object sender, EventArgs e) { MessageBox.Show("Click Executed!"); } } }In the above code, we just declare click event for checkbox1 only, if you will copy paste it multiple times and rename as checkbox2 and checkbox3 then it would not work. Because you have also assigned the event to the event property which is on the right bottom of visual studio. In the following image, you can be observed the output after execution of the code.
using System; using System.Drawing; using System.Windows.Forms; namespace TEP { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { checkBox1.ForeColor = Color.AliceBlue; } private void checkBox1_ForeColorChanged(object sender, EventArgs e) { MessageBox.Show("ForeColorChanged Executed!"); } } }When user will click the button, ForeColor of first C# CheckBox is get changed from Black to AliceBlue. After color get changed ForeColorChanged event get executed the return the message popup. In the following image, you can be observed the output that C# CheckBox1 foreColor gets changed.
using System; using System.Drawing; using System.Windows.Forms; namespace TEP { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void checkBox1_MouseHover(object sender, EventArgs e) { checkBox1.ForeColor = Color.BlueViolet; MessageBox.Show("ForeColorChanged Executed!"); } } }This is a quite good example to demonstrate the MouseHover event. When user will hover the mouse cursor on the CheckBox1 then ForeColor is get changed into Blue Violet. In the following image, you can get the main idea how it looks after the execution.
using System; using System.Drawing; using System.Windows.Forms; namespace strnull { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void checkBox1_MouseHover(object sender, EventArgs e) { checkBox1.ForeColor = Color.BlueViolet; } private void checkBox1_MouseLeave(object sender, EventArgs e) { checkBox1.ForeColor = Color.Black; } } }If you want to execute the above code, then you have to drag one checkbox on your windows form. Then add mouse leave and mouse hover event. Copy the above code and inserted into your compiler and executed. When you will hover the mouse on the checkbox1 its font color gets changed and when leaving the checkbox then fore color get to default.
using System; using System.Drawing; using System.Windows.Forms; namespace TEP { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { checkBox1.Text = "Changed !"; } private void checkBox1_TextChanged(object sender, EventArgs e) { MessageBox.Show("Text Changed !!"); } } }For each checkbox, you have to declare the separate TextChanged event handler. In the above code, we declared it just for the checkbox1. So when the default text of checkbox1 is get changed, TextChanged event get raised. In the following image, you can be observed the output.
JLCPCB – Prototype 10 PCBs for $2 (For Any Color)
China’s Largest PCB Prototype Enterprise, 600,000+ Customers & 10,000+ Online Orders Daily
How to Get PCB Cash Coupon from JLCPCB: https://bit.ly/2GMCH9w