需要帮助撤消字体更改和应用组合字体 [英] need help on undoing the font change and applying combo font

查看:87
本文介绍了需要帮助撤消字体更改和应用组合字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码有效,但如果我再次点击按钮,我就无法撤消应用的字体



到目前为止我的代码





the code works but i cant undo the applied font if i click the button again

heres my code so far


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

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

        private void btnbold_Click(object sender, EventArgs e)
        {

            bool bclicked = false;

            if (bclicked == false)
            {
                txtmessage.Font = new Font(this.Font, FontStyle.Bold);
            }
            else
            {
                txtmessage.Font = new Font(this.Font, FontStyle.Regular);
            }
        }

        private void btnunderline_Click(object sender, EventArgs e)
        {
            bool uclicked = false;

            if (uclicked == false)
            {
                txtmessage.Font = new Font(this.Font, FontStyle.Underline);
            }
            else
            {
                txtmessage.Font = new Font(this.Font, FontStyle.Regular);
            }


        }
        
        private void btnitalic_Click(object sender, EventArgs e)
        {
            bool iclicked = false;

            if (iclicked == false)
            {
                txtmessage.Font = new Font(this.Font, FontStyle.Italic);
            }
            else
            {
                txtmessage.Font = new Font(this.Font, FontStyle.Regular);
            }
        }

        private void txtmessage_TextChanged(object sender, EventArgs e)
        {
 

        }
    }
}

推荐答案

这篇关于需要帮助撤消字体更改和应用组合字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆