Roger Luo

超越梦想一起飞
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

随笔分类 -  C#

1

摘要:SharpSSH sharpssh is a pure .NET implementation of the SSH2 client protocol suite. It provides an API for communication with SSH servers and can be integrated into any .NET application. Download: l... 阅读全文

posted @ 2013-07-07 16:40 Roger Luo 阅读(885) 评论(0) 推荐(0)

摘要:参考http://keyvan.io/host-wpf-controls-in-windows-forms 在windows form appliation中添加wpf空间,需要使用一个ElementHost的容器,接着将创建出来的WPF对象赋值到ElementHost的child属性中,类似子控件添加到Panel或者Form的controls容器中,可以ElementHost只能对应一个wpf控... 阅读全文

posted @ 2013-06-15 15:28 Roger Luo 阅读(3512) 评论(1) 推荐(0)

摘要:WinForm 很多朋友都会在开发WinForm中遇到Label要显示的内容太长,但却不能换行的问题.这里我总结了几种方法,供大家参考: 第一种是把Label的AutoSize属性设为False,手动修改Label的大小.这样的好处是会因内容的长度而自动换行,但是当内容的长度超过所设定的大小时,多出的内容就会无法显示.因此,这种方法适合于基本确定内容长度的时候使用. ... 阅读全文

posted @ 2013-06-14 06:57 Roger Luo 阅读(4174) 评论(0) 推荐(0)

摘要:TreeView添加快键菜单有两种方法: 一种就是使用TreeView的ContextMenuStrip属性,添加一个新ContextMenuStrip,这个方法非常的简答直接,缺点是右键菜单是整个控件响应的,也就是说即使没有右键选中节点也是会触发快捷菜单的显示 这种方法里获取哪一个的node选中是通过这个方法:TreeNode curNode = this.trvFolder.GetNode... 阅读全文

posted @ 2013-04-17 22:46 Roger Luo 阅读(868) 评论(0) 推荐(0)

摘要:TabPage没有Visible属性,所以只能通过设置将其与父控件(tabcontrol)的关联性去除就好了,如下面代码: this.tclMain.Controls["tpgSize"].Parent = null; this.tclMain.Controls["tpgColor"].Parent = null; 上述代码将原本是tabcontrol(tclMain)中的两个TabPag... 阅读全文

posted @ 2013-04-01 08:04 Roger Luo 阅读(6483) 评论(0) 推荐(0)

摘要:以前得到DataSet的时候都是利用直接写sql语句(适合初学者) public static DataSet GetDs(string sqlstr) { ds = new DataSet(); sqlconn = new SqlConnection(); sqlconn.ConnectionString =... 阅读全文

posted @ 2013-03-26 19:20 Roger Luo 阅读(7798) 评论(0) 推荐(0)

摘要:如何获取DataGridViewCheckBoxCell的值 方法1,需要给DATAGRIDVIEW控件添加事件CellContentClick,这里我将CHECKBOX放在数据列的第一个所以我判断参数中COLUMNINDEX是否为0,同时需要注意的是使用属性EditedFormattedValue,不能使用Value值,因为Value值是旧值。 private void dg... 阅读全文

posted @ 2013-03-26 12:48 Roger Luo 阅读(564) 评论(0) 推荐(0)

摘要:MD5的简单的例子 using System.Security.Cryptography;using System.Text;static public void Main() { string line, ret; while (true) { line = Console.ReadLine(); by... 阅读全文

posted @ 2013-03-25 18:58 Roger Luo 阅读(364) 评论(0) 推荐(0)

摘要:private void ResheshState(string msg){ if (lblState.InvokeRequired == true) { lblState.BeginInvoke((MethodInvoker)delegate { lblState.Text = msg; }); } e... 阅读全文

posted @ 2013-03-17 23:04 Roger Luo 阅读(183) 评论(0) 推荐(0)

摘要:C++ fstream fin;fin.open(filename, ios::in);if (!fin.good()){ cerr<<"Failed to open "<<filename<<endl; return -1;}fin.seekg(0, ios::end);size_t len = fin.tellg();char * raw = new char[len+1]... 阅读全文

posted @ 2013-03-16 12:55 Roger Luo 阅读(229) 评论(0) 推荐(0)

摘要:Compression 阅读全文

posted @ 2013-03-05 10:43 Roger Luo 阅读(255) 评论(0) 推荐(0)

摘要:Configuration of MySQL on C# project. 1. Download the assembly from MySQL binary on installing MySQL connector .NET 2. Copy it to your project’s build out directory, such as ‘$ProjectDIR/Bin/Debug’ ... 阅读全文

posted @ 2013-03-03 18:52 Roger Luo 阅读(388) 评论(0) 推荐(0)

摘要:Synchronously loading image PictureBox pbx = new PictureBox();pbx.Image = Image.FromFile(filename);or PictureBox pbx = new PictureBox();pbx.Load(filename); // filename could be the url file:/... 阅读全文

posted @ 2013-03-02 18:36 Roger Luo 阅读(7238) 评论(0) 推荐(0)

摘要:Assuming there are two panels in a winform, show like below. Panel1 Panel2 Panel1.dock is left. Panel2.dock is fill. Right now, add a status bar at the bottom of this wi... 阅读全文

posted @ 2013-03-02 09:57 Roger Luo 阅读(5523) 评论(1) 推荐(1)

摘要:1. Show current time 2. Calculate execution time Use StopWatch classs, which locates in System.Diagnostics namespace. static void Main(string[] args){ Stopwatch s1 = new Stopwatch(... 阅读全文

posted @ 2013-01-24 21:43 Roger Luo 阅读(154) 评论(0) 推荐(0)

摘要:Basic operaiton on xml file in C# Background of XML XML document can be divied into three kinds of schema, DTD, XDR and XSD. Open xml file in synchronous way XmlDocument xml = new XmlDocument()... 阅读全文

posted @ 2013-01-22 22:28 Roger Luo 阅读(260) 评论(0) 推荐(0)

摘要:Task使用Task以及Task.Factory都是在.Net 4引用的。Task跟Thread很类似,通过下面例子可以看到。 static public void ThreadMain() { Thread t1 = new Thread(TaskWorker); t1.Start(3); } static public void TaskMain() { Task t1 = new Task(TaskWorker, 3, TaskCreat... 阅读全文

posted @ 2012-12-27 15:56 Roger Luo 阅读(18913) 评论(0) 推荐(2)

摘要:ThreadPool使用需要定义waitcallback委托形式如public delegate void WaitCallback(object state);例如如下例子: static private void ThreadWorker(object state) { int num = (int)state; if (num > 0) { for (int i = 0; i < 3; i++) { ... 阅读全文

posted @ 2012-12-26 23:36 Roger Luo 阅读(503) 评论(0) 推荐(0)

摘要:WinForm异步编程启动异步线程假定form中具有如下控件一个lable(lblStatus)和一个button(btnStart),并给button添加click事件。实现异步更新方法一: private void StatusAppend(string val) { this.lblStatus.Text += val; } private void SecondlyUpdate(object obj) { int _n = (int)obj; ... 阅读全文

posted @ 2012-12-23 15:47 Roger Luo 阅读(368) 评论(0) 推荐(0)

摘要:大家好,本次讨论的是C#中的并行开发,给力吧,随着并行的概念深入,哥也赶上这个潮流了,其实之前讨论C#的异步调用或者C#中BeginInvoke或者Invoke都已经涉及了部分本篇的内容。参考书目:Professional.C#.4.0.and.NET.4.pdf 以及 Pro .NET 4 Parallel Programming in C#.pdfParallel Program in C#中有Delegate的Asynchronous也有Thread的Asynchronous,前者已经在《C#异步调用详细》中阐述清楚了,那它跟Thread的有什么区别呢?可能大家都混淆了,我也快糊涂了,C 阅读全文

posted @ 2012-12-23 14:12 Roger Luo 阅读(1593) 评论(0) 推荐(0)

1