You are on page 1of 9

UNIVERSITY OF WAH, WAH CANTT

Department of Computer Science

LAB # 05
Advance Programming (BS(CS) 5th A)

CS-315 C# Lab Instructor: Mam Isra Naz

Name: Ali Hassan Reg N0: uw-20m-cs-bs-116

Task1:

using System.Windows.Forms;

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

private void quitToolStripMenuItem_Click(object sender, EventArgs e)


{
Application.Exit();
}

private void copyToolStripMenuItem_Click(object sender, EventArgs e)


{
if(textBox1.SelectedText != " ")
{
textBox1.Copy();
}
else
{
MessageBox.Show("Select some text !");
}
}

private void cutToolStripMenuItem_Click(object sender, EventArgs e)


UNIVERSITY OF WAH, WAH CANTT

Department of Computer Science

{
if(textBox1.SelectedText != " ")
{
textBox1.Cut();
}
else

MessageBox.Show("Select some text !");

private void pasteToolStripMenuItem_Click(object sender, EventArgs e)


{
if(Clipboard.GetDataObject().GetDataPresent(DataFormats.Text)==true)
{
textBox2.Paste();
Clipboard.Clear();
}
}

private void undoToolStripMenuItem_Click(object sender, EventArgs e)


{
if (textBox1.CanUndo==true)
{
textBox1.Undo();
textBox1.ClearUndo();
}
else if (textBox2.CanUndo == true)
{
textBox2.Undo();
textBox2.ClearUndo();
}
}
}
}

Screenshot:
1
UNIVERSITY OF WAH, WAH CANTT

Department of Computer Science

2
Copy:

3
Cut
UNIVERSITY OF WAH, WAH CANTT

Department of Computer Science

4
Undo

Task2:
Code Color:
namespace AliLab5
{
public partial class Form1 : Form
{
public Form1()
{
UNIVERSITY OF WAH, WAH CANTT

Department of Computer Science

InitializeComponent();
}

private void checkBox1_CheckedChanged(object sender, EventArgs e)


{
if (checkBox1.Checked == true)
{
BackColor = Color.Red;
}
}

private void checkBox2_CheckedChanged(object sender, EventArgs e)


{
if(checkBox2.Checked == true)
{
BackColor = Color.Blue;
}
}

private void checkBox3_CheckedChanged(object sender, EventArgs e)


{
if(checkBox3.Checked == true)
{
BackColor = Color.Green;
}
}

private void checkBox4_CheckedChanged(object sender, EventArgs e)


{
if(checkBox4.Checked == true)
{
BackColor = Color.Purple;
}
}

private void checkBox5_CheckedChanged(object sender, EventArgs e)


{
if(checkBox5.Checked == true)
{
BackColor = Color.Orange;
}
}
Screenshot:
1
UNIVERSITY OF WAH, WAH CANTT

Department of Computer Science

3
UNIVERSITY OF WAH, WAH CANTT

Department of Computer Science

Code Font:

private void radioButton1_CheckedChanged(object sender, EventArgs e)


{
if (radioButton1.Checked==true)
{
radioButton1.Font = new Font(radioButton1.Font.FontFamily, 20);

}
}

private void radioButton2_CheckedChanged(object sender, EventArgs e)


{
if (radioButton2.Checked==true)
{
radioButton2.Font = new Font(radioButton2.Font.FontFamily, 30);

}
}

private void radioButton3_CheckedChanged(object sender, EventArgs e)


{
if (radioButton3.Checked==true)
{
radioButton3.Font = new Font(radioButton3.Font.FontFamily, 40);

}
}
UNIVERSITY OF WAH, WAH CANTT

Department of Computer Science

private void radioButton4_CheckedChanged(object sender, EventArgs e)


{
if (radioButton4.Checked==true)
{
radioButton4.Font = new Font(radioButton4.Font.FontFamily, 50);

}
}
}
}

Screenshot:
1

2
UNIVERSITY OF WAH, WAH CANTT

Department of Computer Science

THANK YOU…!!!

You might also like