- 博客(22)
- 资源 (3)
- 收藏
- 关注
原创 UDP
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
2018-01-06 17:59:26
279
转载 C# WinForm窗体及其控件的自适应
一。说明改进C# WinForm窗体及其控件自适应各种屏幕分辨率 二。使用方法 1.把自适应的类整体复制到你的工程命名空间里,(这样做,每个窗体均可使用) 然后在需要自适应的窗体中做2步即可: 2.声明自适应类实例。 3.为窗体添加SizeChanged事件,并在其方法Form1_SizeChanged中,首次记录窗体和其控件初始位置和大小,之后调
2016-10-30 10:19:08
1554
原创 实现一个串口被多个Form窗体调用的功能
很简单,是我自己摸出来的,不要用c#自带的serialPort控件,自己定义一个静态实例即可。 public static SerialPort serialPort1 = new SerialPort();然后连接虚拟串口COM3: private void bt_connectPlc_Click(object sender, EventArgs e)
2016-10-28 19:39:30
6912
2
原创 在Form1中打开另一个窗体Form2
private void tsb_OpenForm2_Click(object sender, EventArgs e) { //设置Form2窗体实例只能是一个,即_form2 if (_form2 == null || _form2.IsDisposed) { _fo
2016-10-28 19:28:05
10814
原创 scatterGraph控件模拟画图
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using Sy
2016-10-24 15:47:10
3010
1
转载 NI Measurement Studio 2013中waveformPlot控件的使用
之前学习编写上位机软件的时候,经常发现在VC中显示波形图相当不方便,后来,通过一位在外面实习回来的师兄说过NI的一个图形库。自己也就在这方面折腾了半天,最后终于弄成了。 开发环境用的是vs2005,编程语言用的是C#,这比MFC要方便,还要快,对于一般的辅助型测试的小软件,这个比MFC更快。我下载的是一个MeasurementStudio 8的库,解压安装库后,再在C#中添加之。
2016-10-17 11:00:59
9168
转载 c# 窗体截图并导出
Bitmap bit = new Bitmap(this.Width, this.Height);//实例化一个和窗体一样大的bitmap Graphics g = Graphics.FromImage(bit); g.CompositingQuality = CompositingQuality.HighQuality;//质量设为最高 g.CopyFromScreen(thi
2016-10-17 10:51:09
530
原创 C#自带的serialPort串口控件
//serialPort1.PortName = "COM4"; serialPort1.PortName = ReadTenCom();//设置串口号,ReadTenCom()是读取串口号的方法,返回的是string类型 serialPort1.ReceivedBytesThreshold = 1;//设置能引发
2016-10-17 10:40:37
9416
原创 ModbusRTU协议中CRC校验码的算法
//生成crc校验码 private ushort Fun_CRC16(byte[] data, ushort length) { ushort reg_crc; ushort s_crcchk; s_crcchk = 0; reg_crc = 0xF
2016-10-17 10:07:53
1370
原创 多线程的使用
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using Sy
2016-10-06 09:39:08
416
原创 委托的用处及匿名函数(lamda表达式)
当你需要把一个方法传送给其他方法时,可以考虑使用委托。好像不是很好理解,也可以这样说,当你确定要处理一件事,但又不能确定处理方法时,可以考虑用委托。其实单独的说委托的应用好像有点牵强,委托更多的是在事件中的应用。using System;using System.Collections.Generic;using System.Linq;using System.Text;
2016-09-04 09:17:11
424
原创 委托概念(难点)
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace 委托概念{ //申明一个委托指向一个函数 delegate void DelSayHi(string name); class Program
2016-09-03 18:18:26
326
原创 委托
利用委托 求解函数y=x*x与x轴所围成的曲边梯形的面积。using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace 委托{ class Program { //被积函数
2016-09-01 12:26:10
307
转载 base关键字
1.base其实最大的使用地方在面相对性开发的多态性上,base可以完成创建派生类实例时调用其基类构造函数或者调用基类上已被其他方法重写的方法。例如:2.关于base调用基类构造函数public classA{publicA(){Console.WriteLine("Build A");}}public class B:A{
2016-08-30 10:56:38
429
原创 捕获异常及自定义异常类
捕获异常: try - catch 收尾工作: try - catch - throw 抛出异常: throw 语句自定义异常类
2016-08-30 10:20:53
692
原创 装箱和拆箱
主要内容: int n = 16; object obj = n;//装箱 Console.WriteLine (obj); int i =(int )obj;//拆箱 Console.WriteLine(i); //注意:装箱拆箱过程损失了程序的性能,尽量少用。
2016-08-29 15:08:03
360
原创 基类向下转换
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace 基类___派生类__向下转换{ class Program { static void Main(string[] args) {
2016-08-27 14:18:20
463
原创 派生类有参构造函数的编程
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace 派生类构造函数{ class Program { static void Main(string[] args) {
2016-08-26 16:49:11
609
原创 索引器访问离散字段(输出有点小问题 暂时还没找到错误。) “homephone”引号里面多打了个 空格键! 导致字符串不匹配
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace 索引器访问离散字段{ class Program { static void Main(string[] args) {
2016-08-25 18:08:38
305
原创 索引器的使用
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace 索引器{ class Program { static void Main(string[] args) {
2016-08-25 16:44:06
209
原创 数组的传递
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace 数组在方法中的传递{ class Program { static void Main(string[] args) {
2016-08-25 10:14:58
408
原创 this 关键字的用法
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace this关键字{ class Time { private int hour; private int minute;
2016-08-25 09:29:58
315
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人