Zoom in & Zoom out Controls in C#
Step1-To zoom in & zoom out we need to add two Buttons, Label from the toolbox.
Step 2- Copy & paste this code to the button1 click event.
private void button1_Click(object sender, EventArgs e)
{
float currentSize;
currentSize = label1.Font.Size;
currentSize += 2.0F;
label1.Font = new Font(label1.Font.Name, currentSize,
label1.Font.Style, label1.Font.Unit);
}
Step 3- To Zoom out copy & paste this code to the button2 click event.
private void button2_Click(object sender, EventArgs e)
{
float currentSize;
currentSize = label1.Font.Size;
currentSize -= 2.0F;
label1.Font = new Font(label1.Font.Name, currentSize,
label1.Font.Style, label1.Font.Unit);
}
Step 2- Copy & paste this code to the button1 click event.
private void button1_Click(object sender, EventArgs e)
{
float currentSize;
currentSize = label1.Font.Size;
currentSize += 2.0F;
label1.Font = new Font(label1.Font.Name, currentSize,
label1.Font.Style, label1.Font.Unit);
}
Step 3- To Zoom out copy & paste this code to the button2 click event.
private void button2_Click(object sender, EventArgs e)
{
float currentSize;
currentSize = label1.Font.Size;
currentSize -= 2.0F;
label1.Font = new Font(label1.Font.Name, currentSize,
label1.Font.Style, label1.Font.Unit);
}
No comments:
Post a Comment