随笔分类 -  C#

C# 语言随笔
摘要:项目中用到矩阵计算,在网上没有搜到合适的矩阵运算类,C#类库中的matrix类又不是很合心意,于是乎自己写了一个,完成后总结了一下,发布了上来。完成的DLL文件及使用例程在文章最后有下载链接使用方法和步骤:一,引用方法1:在你想用的工程中添加引用,引用你所下载的文件 MatrixDevelopTest\MatrixDevelopTest\bin\Debug\Matrix.dll2:在你工程中需要做矩阵计算的类中的最上边加上using CMatrix;就可以在其中使用了。二,Matrix类使用方法1,创建Matrix类的对象,此对象就表示一个矩阵对象,我重载了四种矩阵对象的初始化方法 pub.. 阅读全文
posted @ 2012-12-20 19:59 璇星 阅读(4264) 评论(1) 推荐(0)
摘要:public void UIThread(MethodInvoker method){ if (this.InvokeRequired) { this.Invoke(method); } else { method.Invoke(); }}public void UpdateUI(){ this.UIThread(delegate { this.Label1.Text = "msg1"; this.Label2.Text = "msg2"; });}public void Update... 阅读全文
posted @ 2012-09-22 22:52 璇星 阅读(374) 评论(0) 推荐(0)
摘要: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;namespace WindowsFormsApplication1{ public partial class Form1 : Form { public Form1() { Init... 阅读全文
posted @ 2012-07-31 22:59 璇星 阅读(325) 评论(0) 推荐(0)
摘要:因为要保存些软件的当前设置,又不想对系统有影响,(我想应该没人愿把自己的PC机当小白鼠,没事往里面写注册表玩吧),找了一下可以有两种方法解决1.利用*.ini文件保存设置,读取方便,只是这种文件格式只被win98所提倡,NT 后都建议用注册表了!2.利用*.xml文件进行保存,目前还不太了解,这两天学习一下再记录下来!首先利用*.ini文件进行保存读写操作:由于C#本身并不支持*.ini文件,所以要调用windows API 函数来进行读写在网上找到了段代码,整理了一下如下:1,命名空间中要加入以下引用:此命名空间具体干嘛的不懂,哪天有时间再说)using System.Runtime.Int 阅读全文
posted @ 2012-07-28 22:42 璇星 阅读(1013) 评论(0) 推荐(0)
摘要:C# 中List类的Find,Exists,FindAll,FindIndex ,FindLast ,FindLastIndex等方法的应用举例以Exists为例,MSDN中是这样叙述的确定List<(Of<(T>)>)是否包含与指定谓词所定义的条件相匹配的元素。我一直都认为编写MSDN文档的人语文是好的令人发指啊!相信很多人都深有体会,这里每个字都认识,放一起完全不知所云,看了好多例子才知道是怎么回事,不知道是我肤浅,还是技术总是要深奥。总结一下,写了一个通俗点的例子,希望能对看到的人有用。static void Main(string[] args)//主函数即入口 阅读全文
posted @ 2012-07-28 22:32 璇星 阅读(18030) 评论(0) 推荐(1)
摘要:之前是用INI文件保存的串口设置,为了赶流行,现在都用XML了嘛!改改吧!下面是用XML文件保存串口设置的C#代码。有时间再开发软件的初始化数据保存代码。using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.IO;using System.Xml;namespace TestXMLconsole{ class Program { static void Main(string[] args) { X... 阅读全文
posted @ 2012-07-28 22:06 璇星 阅读(305) 评论(0) 推荐(0)
摘要:主要是响应控件的两个事件:一个是触发鼠标拖动并进入控件区域时,一个是触发鼠标拖动到该控件区域时的释放.拖动的对象需要从这两个事件的参数中获取,及从e中获得. ///先要把接受拖放功能的控件的AllowDrop功能打开. this.textBox2.AllowDrop = true; this.textBox2.Multiline = true; private void textBox2_DragDrop(object sender, DragEventArgs e) { ///创建一个数组类,用于保存拖动进来的数据... 阅读全文
posted @ 2012-06-30 22:06 璇星 阅读(3302) 评论(0) 推荐(0)
摘要:MD5值计算 阅读全文
posted @ 2012-06-30 21:15 璇星 阅读(261) 评论(0) 推荐(0)
摘要:精确的时间计量方法在某些应用程序中是非常重要的。常用的 Windows API 方法 GetTickCount() 返回系统启动后经过的毫秒数。另一方面,GetTickCount() 函数仅有 1ms 的分辨精度,很不精确。 故而,我们要另外寻找一种方法来精确测量时间。 阅读全文
posted @ 2012-05-24 20:37 璇星 阅读(438) 评论(0) 推荐(0)
摘要:For just merging the headercell 阅读全文
posted @ 2012-05-06 21:53 璇星 阅读(6797) 评论(0) 推荐(0)
摘要:A .NET library for generating Word documents (.DOC) using the RTF (Rich Text Format) specification. 利用RTF格式生成word文档的.Net库 阅读全文
posted @ 2012-04-23 21:42 璇星 阅读(758) 评论(0) 推荐(0)
摘要:有时,对串口供电需要设置DtrEnable 和RtsEnable 两个属在开发中有些串口设备需要串口供电,使用C#中的SerialPort类默认情况下不会出发 DataReceived函数,但使用超级终端却可以接收到数据,这是因为 SerialPort 类的DtrEnable 和RtsEnable 两个属性默认是false,设为true即可接收数据了,如下: this.m_SerialPort.DtrEnable = true; //启用控制终端就续信号 this.m_SerialPort.RtsEnable = true; //启用请求发送信号 阅读全文
posted @ 2012-04-17 20:33 璇星 阅读(457) 评论(0) 推荐(1)
摘要:C#操作Excel的类,还需要进一步整理 阅读全文
posted @ 2012-04-13 23:53 璇星 阅读(466) 评论(0) 推荐(0)
摘要: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 System.Diagnostics;using System.Threading;namespace TestOfProcess{ public partial class Form1 : Form { Th... 阅读全文
posted @ 2012-03-24 21:38 璇星 阅读(649) 评论(0) 推荐(0)
摘要:using System;using System.IO;using System.Collections.Generic;using System.Text;using System.Data;using System.Drawing;using System.Windows.Forms;namespace SerialDebug{ /// <summary> /// 标题:将 DataGridView 导出到 Excel 或 Xml 通用类 /// Edit by WL 20110404 /// 描述:导出时可以指定需要导出的 DataGridV... 阅读全文
posted @ 2012-03-03 22:15 璇星 阅读(3095) 评论(1) 推荐(0)
摘要:代码 阅读全文
posted @ 2012-01-07 22:24 璇星 阅读(570) 评论(0) 推荐(1)
摘要: 阅读全文
posted @ 2012-01-07 22:15 璇星 阅读(1759) 评论(0) 推荐(1)
摘要:正常响应CellValueChanged()事件时,当改变checkbox状态时,只有当焦点离开该单元格时才能触发CellValueChanged()事件,如果要改变checkbox值时实时触发CellValueChanged()事件,需要借用CurrentCellDirtyStateChanged()事件来提交未提交控件的更改。 private void dataGridView1_CurrentCellDirtyStateChanged(object sender, EventArgs e) { if (dataGridView1.IsCu... 阅读全文
posted @ 2012-01-02 23:17 璇星 阅读(14424) 评论(1) 推荐(1)
摘要: 阅读全文
posted @ 2011-12-24 14:53 璇星 阅读(7657) 评论(0) 推荐(1)
摘要: 阅读全文
posted @ 2011-12-20 20:23 璇星 阅读(456) 评论(0) 推荐(0)