随笔分类 - C#
C sharp 个人的笔记
摘要:新建winform窗体程序 添加button控件 在事件中选择 MouseEnter 代码如下 private void button_MouseEnter(object sender, EventArgs e) { //给按钮一个新的坐标 //这个按钮活动的最大宽度就是 窗体的宽度减去按钮的宽度
阅读全文
摘要://窗体缩放 const int Guying_HTLEFT = 10; const int Guying_HTRIGHT = 11; const int Guying_HTTOP = 12; const int Guying_HTTOPLEFT = 13; const int Guying_HTT
阅读全文
摘要:1、新建一个窗体程序,添加一个Timer以及设置它可用并绑定事件。 2、设置窗体的TopMost属性为True 3、然后设置代码如下即可实现 private void Form1_Load(object sender, EventArgs e) { timer1.Start(); } private
阅读全文
摘要:C# 窗体永远在最前 1、调用系统API public const int HWND_TOP = 0; public const int HWND_BOTTOM = 1; public const int HWND_TOPMOST = -1; public const int HWND_NOTOPM
阅读全文
摘要:private void Form1_Load(object sender, EventArgs e) { Rectangle ScreenArea = System.Windows.Forms.Screen.GetWorkingArea(this);//GetWorkingArea()检索显示器的
阅读全文
摘要:c# winform窗体,点击窗体标题头可以拖动,如果鼠标点击在里面的panel的时候就没有这个效果了,以下实现拖动的方法。 转载自醉低调 public partial class Form1 : Form { public Form1() { InitializeComponent(); } [D
阅读全文
摘要:其实图片上传时使用文件控件最为方便,但如何考虑到数据库存储等,可以可虑转换为字节流。 Bitmap => byte[] Bitmap b = new Bitmap( "test.bmp "); MemoryStream ms = new MemoryStream(); b.Save(ms,Syste
阅读全文
摘要:public void ReNewHelper() { new Thread(() => { string strInput = "ipconfig/renew"; Process p1 = new Process(); //设置要启动的应用程序 p1.StartInfo.FileName = "c
阅读全文
摘要:string str = "中国"; byte[] bufOfGB = System.Text.Encoding.GetEncoding("gb2312").GetBytes(str); Array.ForEach(bufOfGB,m=>Console.WriteLine(m)); Console.
阅读全文
摘要:直接放代码了 简单易懂 方法代码 // 获取全局 开始 文件夹位置 string directory = Environment.GetFolderPath(Environment.SpecialFolder.CommonStartup); // 获取当前登录用户的 开始 文件夹位置 //Envir
阅读全文
摘要:首先右键项目 新建 添加一个应用程序清单文件 找到requestedExecutionLevel 我直接放代码了 一看就懂 <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> level改成require
阅读全文
摘要:在Windows中创建快捷方式很简单,直接用右键点击文件或文件夹,选择创建快捷方式即可。如果想用C#代码的方式创建,就没有那么方便了,因为.NET框架没有提供直接创建快捷方式的方法。 首先我们看一下快捷方式是什么。对快捷方式点右键,选择属性菜单,在弹出的属性对话框的常规Tab中可以看到,文件类型是快
阅读全文
摘要:System.Diagnostics.Process.Start("https://www.cnblogs.com/hack747/");
阅读全文
摘要:1 private void button2_Click(object sender, EventArgs e) 2 { 3 if (File.Exists(@"E:\exists.txt")) 4 { 5 MessageBox.Show("文件存在"); 6 } 7 else 8 { 9 Mess
阅读全文
摘要:Directory.CreateDirectory();
阅读全文
摘要:1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using System.Data; 5 using System.Drawing; 6 using System.Linq; 7
阅读全文
摘要:System.Environment.Exit(0);
阅读全文
摘要:MetroModernUI库应用实例 本文将详细描述MetroModernUI库的安装过程及基本的使用方法。[toc] 安装流程 搜索并安装MetroModernUI库 对项目右键单击,选择“管理NuGet程序包” 在【1】中输入“Metro”执行搜索,待显示所有结果后选择与【2】中信息相同的项,单
阅读全文
摘要:System.Diagnostics.Process.Start的妙用: 文件夹打开时自动选中一个文件,比如自动选中此目录下的指定文件方法: Process.Start("Explorer", "/select," + filePath); 我们经常会遇到在Winform或是WPF中点击链接或按钮打
阅读全文
摘要:Console.WriteLine(System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)); System.Environment.GetFolderPath 方法 获取指向由指定枚举标识的系统特殊文件夹的路径
阅读全文