⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 thisdocument.cs

📁 这是.net2005学习不可缺少的教程
💻 CS
字号:
using System;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using Microsoft.VisualStudio.Tools.Applications.Runtime;
using Word = Microsoft.Office.Interop.Word;
using Office = Microsoft.Office.Core;

namespace demoword
{
    public partial class ThisDocument
    {
        private Word.Range range;
        public float FontSize = 15.0f;
        private void ThisDocument_Startup(object sender, System.EventArgs e)
        {
            object start = System.Reflection.Missing.Value;
            object end = System.Reflection.Missing.Value;
            range = this.Range(ref start, ref end);
            range.Font = new Word.FontClass();
            range.Font.Name = "Arial";
            range.Font.Size = FontSize;
        }

        private void ThisDocument_Shutdown(object sender, System.EventArgs e)
        {
        }

        #region VSTO Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InternalStartup()
        {
            this.button1.Click += new System.EventHandler(this.button1_Click);
            this.button2.Click += new System.EventHandler(this.button2_Click);
            this.Startup += new System.EventHandler(this.ThisDocument_Startup);
            this.Shutdown += new System.EventHandler(this.ThisDocument_Shutdown);

        }

        #endregion

        private void button2_Click(object sender, EventArgs e)
        {
            FontSize += 1;
            range.Font.Size = FontSize;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            SizeDlg dlg = new SizeDlg(this);
            dlg.Show();
        }
        public void setSize(float size)
        {
            range.Font.Size = size;
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -