Write a program to increase and decrease font size programmatically.
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Windows.Forms;
namespace
WindowsFormsApplication3
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
static public Font ChangeFontSize(Font
font, float fontsize)
{
if (font != null)
{
float currentsize = font.Size;
if (currentsize != fontsize)
{
font = new Font(font.Name,
fontsize, font.Style, font.Unit);
}
}
return font;
}
private void button1_Click(object
sender, EventArgs e)
{
label1.Font = ChangeFontSize(label1.Font,
label1.Font.Size * 2);
}
private void button2_Click(object
sender, EventArgs e)
{
label1.Font =
ChangeFontSize(label1.Font, label1.Font.Size - 15);
}
}
}