Write a program to increase and decrease font size programmatically.


using System;
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);
        }
    }
}

Popular posts from this blog

Write a program to check whether empty query string is entered in Asp.Net.

Mandavrayji Temple, Muli, Surendranagar, Gujarat

Write a program to change color of Label text control programmatically in Asp.Net.