1.KeyEventArgs.Handled 属性
获取或设置将路由事件标记为已处理的值。如果 Handled 的值为 true,则可以防止事件路由路径上的大多数处理程序再次处理同一事件。
2. e.keychar和e.keycode有什么区别?
KeyChar获得是字符,类型是Char,是KeyPressEventArgs类的属性
KeyCode获得是键码,类型是Keys枚举,是KeyEventArgs类的属性
48--〉0
57 --〉9
2者的区别是在处理控制键上面,比如CTRL,SHIFT以及ALT。
当用户同时按下 CTRL + C 的时候,KeyDown事件会相应两次,KeyCode的值分别会是 CTRL键 和 C键。但是随后的KeyPress会相应一次,产生的KeyChar的值是3。
若是用户在按住CTRL + C不放的话,KeyDown和KeyPress会一直交替引发,但是这个时候,KeyDown就只有 C 键了(CTRL键不再引发该事件),KeyPress就是3.
3. C# 中keychar 数值对应 键值(键盘上键值)
8 --〉 Backspace
13 --〉enter
4. RichTextBox 的 SelectionFont 为空的问题
参见:
http://www.seebit.org/2007/01/richtextbox-selectionfont-null/
5. RichTextBox.SelectionFont 属性
获取或设置当前选定文本或插入点的字体。
6. 遍历一个窗体中的某一种控件 c#实现
http://blog.csdn.net/vsweaver/archive/2006/05/26/756065.aspx
7. C#调用外部程序。
using System.Diagnostics;
8. c#判断程序是否运行
9. C#中 定义类似于VB中的Right,Left,Mid方法
10. 最小化主窗体
11. c# 后台运行 .bat file。
12. c# 启动进程的 3种方法
(1).启动子进程,不等待子进程结束
(2)启动子进程,等待子进程结束,并获得输出
(3)使用默认的浏览器打开URL
13. c#操作 Excel 方法。
http://blog.csdn.net/zhaobisha/archive/2009/02/04/3862568.aspx
http://lordong.net/wp/post/215.html
http://www.cnblogs.com/shouzheng/archive/2007/09/26/906941.html
http://hi.baidu.com/gamevip/blog/item/8f37d400257f7e12738b65a9.html
14. C# 绘制统计图相关参考网址
http://www.cnblogs.com/ziyiFly/archive/2008/09/24/1297841.html
15. c# 在 RichTextBox 换行。
用 "/r/n" 就 OK,用"/n"不能再RichTextBox中换行。
16. c# 获取当前路径的方法集合
//获取当前进程的完整路径,包含文件名(进程名)。
string str = this.GetType().Assembly.Location;
result: X:\xxx\xxx\xxx.exe (.exe文件所在的目录+.exe文件名)
//获取新的 Process 组件并将其与当前活动的进程关联的主模块的完整路径,包含文件名(进程名)。
string str = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
result: X:\xxx\xxx\xxx.exe (.exe文件所在的目录+.exe文件名)
//获取和设置当前目录(即该进程从中启动的目录)的完全限定路径。
string str = System.Environment.CurrentDirectory;
result: X:\xxx\xxx (.exe文件所在的目录)
//获取当前 Thread 的当前应用程序域的基目录,它由程序集冲突解决程序用来探测程序集。
string str = System.AppDomain.CurrentDomain.BaseDirectory;
result: X:\xxx\xxx\ (.exe文件所在的目录+"\")
//获取和设置包含该应用程序的目录的名称。
string str = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
result: X:\xxx\xxx\ (.exe文件所在的目录+"\")
//获取启动了应用程序的可执行文件的路径,不包括可执行文件的名称。
string str = System.Windows.Forms.Application.StartupPath;
result: X:\xxx\xxx (.exe文件所在的目录)
//获取启动了应用程序的可执行文件的路径,包括可执行文件的名称。
string str = System.Windows.Forms.Application.ExecutablePath;
result: X:\xxx\xxx\xxx.exe (.exe文件所在的目录+.exe文件名)
//获取应用程序的当前工作目录(不可靠)。
string str = System.IO.Directory.GetCurrentDirectory();
result: X:\xxx\xxx (.exe文件所在的目录)
17. C#操作注册表方法
http://www.cnblogs.com/whitetiger/archive/2008/04/09/1144219.html
http://heisetoufa.iteye.com/blog/400466
举例:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Win32;
namespace RegWrite
{
class Program
{
static void Main(string[] args)
{
try
{
RegistryKey key = Registry.CurrentUser;
RegistryKey software = key.OpenSubKey("SOFTWARE", true);
RegistryKey aspentech = software.OpenSubKey("AspenTech", true);
aspentech.SetValue("UserRegistered", "1");
}
catch (Exception e)
{
Console.WriteLine("Write system register exception: " + e.ToString());
}
}
}
}
18 . WPF 中 processbar 应用
http://www.cnblogs.com/bear831204/archive/2010/11/11/1874793.html
19. 日期时间格式化
参考:http://51xingfu.blog.51cto.com/219185/46222