• winform记事本初步实现


     

    复制代码
     public Form1()
            {
                InitializeComponent();
            }
    
            private void 剪切TToolStripMenuItem_Click(object sender, EventArgs e)
            {
                richTextBox1.Cut();
            }
    
            private void 复制CToolStripMenuItem_Click(object sender, EventArgs e)
            {
                richTextBox1.Copy();
            }
    
            private void 粘贴PToolStripMenuItem_Click(object sender, EventArgs e)
            {
                richTextBox1.Paste();
            }
    
            private void 撤消UToolStripMenuItem_Click(object sender, EventArgs e)
            {
                richTextBox1.Undo();
            }
    
            private void 重复RToolStripMenuItem_Click(object sender, EventArgs e)
            {
                richTextBox1.Redo();
            }
    
            private void 全选AToolStripMenuItem_Click(object sender, EventArgs e)
            {
                richTextBox1.SelectAll();
            }
    
            private void toolStripStatusLabel2_Click(object sender, EventArgs e)
            {
                
            }
    
            private void 自动换行ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                if (richTextBox1.WordWrap)
                {
                    自动换行ToolStripMenuItem.Checked = false;
                    richTextBox1.WordWrap = false;
                    toolStripStatusLabel4.Text = "1";
                    toolStripStatusLabel6.Text = richTextBox1.TextLength.ToString();
                }
                else
                {
                    自动换行ToolStripMenuItem.Checked = true;
                    richTextBox1.WordWrap = true;
                }
            }
    
            private void richTextBox1_TextChanged(object sender, EventArgs e)
            {
                toolStripStatusLabel2.Text = richTextBox1.TextLength.ToString();//字符数
    
                toolStripStatusLabel4.Text = richTextBox1.Lines.Length.ToString();//行号
               
                toolStripStatusLabel6.Text = (richTextBox1.SelectionStart - richTextBox1.GetFirstCharIndexOfCurrentLine()).ToString();//焦点所在列数
            }
    
            private void richTextBox1_Click(object sender, EventArgs e)
            {
                toolStripStatusLabel6.Text = (richTextBox1.SelectionStart - richTextBox1.GetFirstCharIndexOfCurrentLine()).ToString();//焦点所在列数
                
                int index = richTextBox1.GetFirstCharIndexOfCurrentLine();//GetFirstCharIndexOfCurrentLine()当前行第一个字符的索引
                //GetLineFromCharIndex(index)指定位置的索引行号
                toolStripStatusLabel4.Text = (richTextBox1.GetLineFromCharIndex(index) + 1).ToString();//焦点所在行号
            }
  • 相关阅读:
    单位rem 触屏适配总结
    汉字转拼音插件:LM-PinYin.js
    PngOptimizer PNG压缩工具
    H5微信场景应用 audio模块
    LM_ReadImgMode.js PC单页轮播读图模式组件,零依赖!
    js中的eval方法
    IE6利用iframe遮挡 弹层 select
    H5 video安卓默认点击不能全屏播放解决办法
    JS正则截取两个字符串之间的字符串
    定宽320 缩放适配手机屏幕
  • 原文地址:https://www.cnblogs.com/baimangguo/p/6159829.html
Copyright © 2020-2023  润新知