NetBlog主题

WinForm 实现颜色渐变
WinForm技巧

WinForm 实现颜色渐变

525

效果图(可以实现左右,或上下乖渐变)核心代码private void panel1_Paint(object sender, PaintEventArgs e){//这个为panel1控件,注册Paint事件 Graphics g = e.Graphics;//先封装一个GDI和绘图图面 Color FColor = Color.FromArgb(255,107,176);//自定义一个RGB颜色…

C#,WinForm DataGridView添加行号
WinForm技巧

C#,WinForm DataGridView添加行号

718

效果图核心代码//注册事件 this.dataGridView1.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(this.dataGridView1_CellPainting);private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e){ if …

winform 无边框 实现拖动
WinForm技巧

winform 无边框 实现拖动

741

核心代码private Point mPoint;//定义一个位置信息Point用于存储鼠标位置//控件注册下面两个事件private void panelTop_MouseDown(object sender, MouseEventArgs e){ mPoint = new Point(e.X, e.Y);}/// summary/// 鼠标移动/// /summary/// param name="send…

C# WinForm 控件自适应窗体大小
WinForm技巧

C# WinForm 控件自适应窗体大小

3037

效果如下1、自动适应窗体类的代码public class AutoAdaptWindowsSize{ double formOriginalWidth;//窗体高度原始宽度 double formOriginalHeight;//窗体原始 double scaleX;//水平缩放比例 double scaleY;//垂直缩放比例 Dictionarystring, string Cont…

C# 截图功能实例源码
WinForm技巧

C# 截图功能实例源码

1070

效果在这里我们用的是 ScreenCapturerSharp库,要在nuget里面安装,或直接引用它的dll核心代码private void button1_Click(object sender, EventArgs e){ this.Hide(); System.Threading.Thread.Sleep(200); ScreenCapturer.ScreenCapturerTool screenCapturer = …