
C#
无声蝉
这个作者很懒,什么都没留下…
展开
-
C# 获取目录相关操作汇总
1、代码private void button1_Click(object sender, EventArgs e){ //1-获取模块的完整路径。 string path1 = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName; //2-获取和设置当前目录(该进程从中启动的目录)的...原创 2018-10-19 15:51:38 · 280 阅读 · 0 评论 -
C#Invoke委托在多线程中的使用
一步一步跟随着我的脚步看一看Form上我设置一个button,text属性为“点击开始测试”;现在我想点击它以后,动态变化从1~10赋值(1)第一个映入脑中的方式就是这样写private void button1_Click(object sender, EventArgs e){ button1.Enabled = false; for(int i=1;i&l...原创 2018-10-19 21:15:07 · 6480 阅读 · 1 评论 -
C# 公共控件之TreeView
1、初始化控件,添加根节点,子节点public Form1(){ InitializeComponent(); InitTreeView();}private void InitTreeView(){ TreeNode parrentNode1 = treeView1.Nodes.Add("父节点1"); parrentNode1.Nodes.Add(...原创 2018-10-17 11:27:25 · 545 阅读 · 0 评论 -
C# 公共控件之progressBar、 toolTip
1、窗体中加入控件progressBar1, toolTip1,timer1 和三个button2、代码如下:private void button1_Click(object sender, EventArgs e)//开始{ timer1.Enabled = true; button1.Enabled = false; button2.Enabled ...原创 2018-10-17 13:57:51 · 390 阅读 · 0 评论 -
C# 公共控件之pictureBox
1、添加控件2、分别实现是三个button功能 private void 打开_Click(object sender, EventArgs e) { string pathname = string.Empty; OpenFileDialog file = new OpenFileDialog(); ...原创 2018-10-17 15:41:37 · 1424 阅读 · 0 评论 -
C# 公共控件之richTextBox
1、添加控件2、添加代码 button1(颜色),button2(字体),button3(查看效果)// 直接接口更改 字体和颜色// AppendTextColorful(richTextBox1, string.Format("图像显示操作!"), 10, Color.Blue, true);//private void AppendTextColorful(RichText...原创 2018-10-17 16:45:13 · 1717 阅读 · 0 评论 -
C# 对话框之FolderBrowserDialog
像saveFileDialog,openFileDialog,colorDialog,fontDialog前面已经涉及了,还差一个FolderBrowserDialog,所有对话框控件就介绍完了,下面就解决完这个小尾巴。1、添加控件textBox1,button12、代码如下:private void button1_Click(object sender, EventArgs ...原创 2018-10-17 17:00:47 · 21129 阅读 · 0 评论 -
C#菜单和工具栏之contextMenuStrip、menuStrip、statusStrip、toolStrip和toolStripContainer
1、contextmenustrip:上下文菜单(鼠标右键菜单)2、menustrip:普通(窗体)菜单3、statusStrip状态栏4、toolStrip工具栏,可导入ico图标5、ToolStripContainer这个控件其实很有意思,网上资料确很少,应该是不太好用,但是如果系统比较大了,工具栏多的话还是可以一用的。其实就是个工具栏容器,软件运行起来后,允许我们...原创 2018-10-17 17:32:51 · 5576 阅读 · 0 评论 -
C# Marshal
参见:关于Marshal 类的整理在两个不同的实体(两个线程或者进程甚至机器、在Managed和Unmanaged之间)进行方法调用和参数传递的时候,具体的调用方法和参数的内存格式可能需要一定的转换,这个转换的过程叫做Marshal。Marshal就是把一个结构(类)序列化成一段内存,然后送到另一个进程(.net中Application domain)中供另一个进程中的函数使用。比如你的...原创 2018-10-22 16:34:16 · 6948 阅读 · 0 评论 -
C#组件之backgroundWorker
这篇文章写得很好 C# BackgroundWorker 详解,一步一步描述很清楚1、添加控件backgroundWorker1 组件label1、label2 用于显示过程和结果信息progressBar1 显示后台处理进度button1 ...原创 2018-10-17 19:45:42 · 591 阅读 · 0 评论 -
C#组件之serialPort、imageList、process
serialPortserialPort1.IsOpenserialPort1.Close()serialPort1.WriteserialPort1.ReadserialPort1.DataReceivedserialPort1.BaudRateserialPort1.Open()serialPort1.PortNameimageList使用ImageList控件存...原创 2018-10-24 15:50:39 · 320 阅读 · 0 评论 -
C#下分别调用C++/C#生成的dll文件
1、C#下分别调用C++生成的dll文件第一步,新建项目选择 Win32控制台应用程序或者Win32项目均可点击“确定”后,选择DLL 和 空项目,点击“完成”添加文件“MyDll.h” “MyDll.cpp”#pragma once#define EXEAPI extern "C" __declspec(dllexport) // C方式导出函数EXEAPI ...原创 2018-10-19 15:34:51 · 338 阅读 · 0 评论 -
C# 公共控件之numericUpDown
1、属性Increment 设置步进值,默认为1Maximun Minimum 设置最大值最小值DecimalPlaces 设置小数点位数,默认为0Hexadecimal 获取或者设置一个值,该值指示显示框是否以十六进制的格式显示包含的值InterceptArrowKeys 是否允许用户使用上下...原创 2018-10-16 20:04:53 · 1767 阅读 · 0 评论 -
C# 公共控件之NotifyIcon 将窗口最小化到托盘
1、设置窗体和notifyIcon属性notifyIcon ,添加contextMenuStrip控件并集成到notifyIcon 的ContextMenuStrip上。窗体2、代码using System;using System.Collections.Generic;using System.ComponentModel;using System.D...原创 2018-10-16 19:47:38 · 905 阅读 · 0 评论 -
C#组件之errorProvider 、eventLog、helpProvider、performanceCounter
errorProvider 给控件绑定错误消息errorProvider1.SetError(textBox1, "错误提示消息");eventLog 写入Windows事件日志EventLog类在System.Diagnostics命名空间中。可以在“管理工具” > "事件查看器“中可以查看我们写入的Windows日志。helpProvider 帮助控件的使用按F...原创 2018-10-18 10:16:48 · 397 阅读 · 0 评论 -
C# 版本号
版本号获取:label1.Text = "程序集版本:" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + "\n";label1.Text += "文件版本:" + Application.ProductVersion.ToString() + "\n";label1.T...原创 2018-10-08 17:14:22 · 1115 阅读 · 0 评论 -
C# 公共控件之webBrowser
操作:单击Button,弹出textBox输入网址代码:public Form1(){ InitializeComponent(); webBrowser1.ScriptErrorsSuppressed = true; //禁止错误脚本弹出}private void button1_Click(object sender, EventArgs e){ ...原创 2018-10-08 18:03:30 · 260 阅读 · 0 评论 -
C# FrameWorkAPI 之 System.Drawing
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....原创 2018-10-18 16:20:46 · 1747 阅读 · 0 评论 -
C# 公共控件之RadioBox ,CheckBox
通常RadioBox称为单选按钮,CheckBox称为多选按钮,这两个控件都是从ButtonBase类中派生,可以将其视为按钮。 多个checkBox之间的选择是互相独立的,互补影响。多个RadioButton之间是互斥的,只能选择其中一个。同一个容器下的多个RadioButton之间互斥,来自不同容器的RadioButton 对象是相对独立的。RadioButton和CheckBox控...原创 2018-10-15 15:45:17 · 2808 阅读 · 0 评论 -
C# 公共控件之Checkbox和CheckedListBox
Winform的开发基本都是基于控件事件的,也就是事件驱动型的。多选框的放置和值的获取有很多种,这里介绍几个简单常用的方法1、直接放置Checkbox,并获取Checkbox的值上图做法也非常简单,就是在form中放置多个checkbox,然后循环遍历,检查其checked没有,然后将checkbox.text拼接到一起,赋值给label,当然实际开发中,我们会将选取的值放入数据库...转载 2018-10-15 15:59:21 · 2429 阅读 · 2 评论 -
C# 公共控件之ListBox
Winform控件ListBox的用法1、如何添加listBox的值this.listBox1.Items.Add("张晓东");2、如何判断listBox集合是否添加过//检查添加值是否添加过if(this.listBox1.items.Contains("张晓东")){ MessageBox.show("集合成员已添加过!"); }else{ ...原创 2018-10-15 16:10:13 · 2425 阅读 · 1 评论 -
c# FrameworkAPI之StackTrace、StackFrame
命名空间:System.DiagnosticsStackTrace 堆栈 跟踪StackFrame 堆栈 帧StackTrace st = new StackTrace(true);string stackIndent = "";for(int i =0; i< st.FrameCount; i++ ){ // Note that at this leve...原创 2018-10-09 10:17:52 · 1060 阅读 · 0 评论 -
C# FrameworkAPI之Mutex实现应用程序单例
using System;using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;using System.Windows.Forms;namespace Demo优快云{ static class Program { /// <summa...原创 2018-10-09 11:08:38 · 366 阅读 · 0 评论 -
C# FrameworkAPI之Socket通信
服务端:1:创建一个socket的对象Socket socketserver=new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);第一个参数是指定socket对象使用的寻址方案,即IPV4或IPV6;第二个参数socket对象的套接字的类型,此处stream是表示流式套接字第三个参...转载 2018-10-16 11:21:00 · 1317 阅读 · 0 评论 -
C# 公共控件之ListView
private void InitListView() { // Create a new ListView control.或者 用工具箱 ListView listView1 = new ListView(); listView1.Bounds = new Rectangle(new Point(10, ...原创 2018-10-16 15:49:47 · 310 阅读 · 0 评论 -
C# 公共控件之 dateTimePicker
此控件用起来简单public Form1(){ InitializeComponent(); // Set the MinDate and MaxDate. dateTimePicker1.MinDate = new DateTime(1985, 6, 20); dateTimePicker1.MaxDate = DateTime.Today; /...原创 2018-10-16 15:58:54 · 569 阅读 · 0 评论 -
C# 公共控件之maskedTextBox
IP地址框1、添加 maskedTextBox 控件2、设置属性3、设定MouseLeave事件private void IPAddressOnMouseLeave(object sender, EventArgs e){ int i=0; int temp = 0; label1.Text = maskedTextBox1.Text.Replace...原创 2018-10-16 17:44:00 · 5780 阅读 · 1 评论 -
C# 委托
在C#中,委托在语法上总是接受一个参数的构造函数,这个参数就是委托引用的方法。例1:public delegate int MethodDelegate(int x, int y);private static MethodDelegate method;static void Main(string[] args){ method = new MethodDelegate(...原创 2018-11-01 10:04:23 · 353 阅读 · 0 评论