在好例子网,分享、交流、成长!
您当前所在位置:首页C# 开发实例C#语言基础 → 多重复制小工具(源码)

多重复制小工具(源码)

C#语言基础

下载此实例
  • 开发语言:C#
  • 实例大小:0.08M
  • 下载次数:12
  • 浏览次数:221
  • 发布时间:2020-01-15
  • 实例类别:C#语言基础
  • 发 布 人:mark1232019
  • 文件格式:.zip
  • 所需积分:2
 相关标签: 复制 工具

实例介绍

【实例简介】可以快速复制文本框中的值

【实例截图】


from clipboard


from clipboard

【核心代码】

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
 
namespace MultiCopy
{
    public partial class Form1 : Form
    {
        private FormDock formDock = null;
        #region 写INI文件
        private string FileName;
        [DllImport("kernel32")]
        private static extern bool WritePrivateProfileString(string section, string key, string val, string filePath);
        [DllImport("kernel32")]
        private static extern int GetPrivateProfileString(string section, string key, string def, byte[] retVal, int size, string filePath);

        public void WriteIni(string Section, string Ident, string Value)
        {
            if (!WritePrivateProfileString(Section, Ident, Value, FileName))
            {
                throw (new ApplicationException("写入配置文件出错"));
            }

        }
        #endregion

        #region 读取INI文件指定
        public string ReadIni(string Section, string Ident, string Default)
        {
            Byte[] Buffer = new Byte[65535];
            int bufLen = GetPrivateProfileString(Section, Ident, Default, Buffer, Buffer.GetUpperBound(0), FileName);
            //必须设定0(系统默认的代码页)的编码方式,否则无法支持中文
            string s = Encoding.GetEncoding(0).GetString(Buffer);
            s = s.Substring(0, bufLen);
            return s.Trim();
        }
        #endregion
        public Form1()
        {
            InitializeComponent();
            formDock = new FormDock(this,300);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if(textBox1.Text != "")
          Clipboard.SetDataObject(textBox1.Text);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox2.Text != "")
                Clipboard.SetDataObject(textBox2.Text);
        }

        private void button3_Click(object sender, EventArgs e)
        {
            if (textBox3.Text != "")
                Clipboard.SetDataObject(textBox3.Text);
        }

        private void button4_Click(object sender, EventArgs e)
        {
            if (textBox4.Text != "")
                Clipboard.SetDataObject(textBox4.Text);
        }

        private void button5_Click(object sender, EventArgs e)
        {
            if (textBox5.Text != "")
                Clipboard.SetDataObject(textBox5.Text);
        }

        private void button6_Click(object sender, EventArgs e)
        {
            if (textBox6.Text != "")
                Clipboard.SetDataObject(textBox6.Text);
        }

        private void button7_Click(object sender, EventArgs e)
        {
            if (textBox7.Text != "")
                Clipboard.SetDataObject(textBox7.Text);
        }

        private void button8_Click(object sender, EventArgs e)
        {
            if (textBox8.Text != "")
                Clipboard.SetDataObject(textBox8.Text);
        }

        private void button9_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";
            textBox4.Text = "";
            textBox5.Text = "";
            textBox6.Text = "";
            textBox7.Text = "";
            textBox8.Text = "";
        }

        private void button10_Click(object sender, EventArgs e)
        {
            if (textBox9.Text != "")
                Clipboard.SetDataObject(textBox9.Text);
        }

        private void button11_Click(object sender, EventArgs e)
        {
            if (textBox10.Text != "")
                Clipboard.SetDataObject(textBox10.Text);
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Directory.CreateDirectory(Application.StartupPath   "\\Config");//创建文件夹fs
            FileName = Application.StartupPath   "\\Config\\copyCfg.ini";

            textBox1.Text = ReadIni("T1", "t1", "");
            textBox2.Text = ReadIni("T2", "t2", "");
            textBox3.Text = ReadIni("T3", "t3", "");
            textBox4.Text = ReadIni("T4", "t4", "");
            textBox5.Text = ReadIni("T5", "t5", "");
            textBox6.Text = ReadIni("T6", "t6", "");
            textBox7.Text = ReadIni("T7", "t7", "");
            textBox8.Text = ReadIni("T8", "t8", "");
            textBox9.Text = ReadIni("T9", "t9", "");
            textBox10.Text = ReadIni("T10", "t10", "");  
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            WriteIni("T1", "t1", textBox1.Text);
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            WriteIni("T2", "t2", textBox2.Text);
        }

        private void textBox3_TextChanged(object sender, EventArgs e)
        {
            WriteIni("T3", "t3", textBox3.Text);
        }

        private void textBox4_TextChanged(object sender, EventArgs e)
        {
            WriteIni("T4", "t4", textBox4.Text);
        }

        private void textBox5_TextChanged(object sender, EventArgs e)
        {
            WriteIni("T5", "t5", textBox5.Text);
        }

        private void textBox6_TextChanged(object sender, EventArgs e)
        {
            WriteIni("T6", "t6", textBox6.Text);
        }

        private void textBox7_TextChanged(object sender, EventArgs e)
        {
            WriteIni("T7", "t7", textBox7.Text);
        }

        private void textBox8_TextChanged(object sender, EventArgs e)
        {
            WriteIni("T8", "t8", textBox8.Text);
        }

        private void textBox9_TextChanged(object sender, EventArgs e)
        {
            WriteIni("T9", "t9", textBox9.Text);
        }

        private void textBox10_TextChanged(object sender, EventArgs e)
        {
            WriteIni("T10", "t10", textBox10.Text);
        }
        
    }

}

标签: 复制 工具

实例下载地址

网友评论

第 1 楼 1875794774 发表于: 2020-03-08 07:02 51
带走了 2020年3月8日07:02:31

支持(0) 盖楼(回复)

发表评论

(您的评论需要经过审核才能显示)

查看所有1条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警