This document provides a lab manual for programming using C# that describes how to use various Windows form controls like labels, text boxes, buttons, check boxes and radio buttons. It includes code snippets to change the font style and color of a label based on check boxes and radio buttons selected, and displays text from text boxes on the label.
1. PROGRAMMING USING C#
LAB MANUAL
SARASWATHI RAMALINGAM
SRI AKILANDESWARI WOMENS COLLEGE
THIRUVALLUVAR UNIVERSITY
2. Windows Form Controls (Label,
Text, Button, Check Box, Radio)
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 CONTROLS1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
3. private void button1_Click(object sender, EventArgs e)
{
if (checkBox1.Checked == true)
label4.Font = new Font(label4.Font, FontStyle.Bold);
if (checkBox2.Checked == true)
label4.Font = new Font(label4.Font, FontStyle.Italic);
if (checkBox3.Checked == true)
label4.Font = new Font(label4.Font, FontStyle.Underline);
if (checkBox4.Checked == true)
label4.Font = new Font(label4.Font, FontStyle.Strikeout);
4. if (radioButton1.Checked == true)
label4.ForeColor = System.Drawing.Color.Red;
else if (radioButton2.Checked==true)
label4.ForeColor = System.Drawing.Color.Green;
else if (radioButton3.Checked==true)
label4.ForeColor = System.Drawing.Color.Pink;
label4.Text = "Name:" + textBox1.Text + "n" + "Message:" +
textBox2.Text;
}
}
}