资源简介
为Winform中的Textbox添加圆角和边框,圆角大小和边框大小可以设置
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;
namespace WindowsFormsApplicationGDI
{
[ToolboxItem(true)]
public class MyTextbox:TextBox
{
///
/// 圆角值
///
[Browsable(true)]
public int Radius { get; set; } = 5;
public int BorderWidth { get; set; } = 2;
public Color BorderColorForMouseHover { get; set; } = SystemColors.ButtonHighlight;
protected override void onresize(EventArgs e)
{
base.onresize(e);
this.Region= Region = new Region(GetRegionPath());
}
///
/// 获取窗体有效区域路径
///
///
private GraphicsPath GetRegionPath()
{
var graphicsPath = new GraphicsPath();
graphicsPath.StartFigure();
graphicsPath.AddArc(this.ClientRectangle.Left this.ClientRectangle.Top Radius * 2 Radius * 2 180 90);
graphicsPath.AddArc(this.ClientRectangle.Right - Radius * 2 this.ClientRectangle.Top Radius * 2 Radius * 2 270 90);
graphicsPath.AddArc(this.ClientRectangle.Right - Radius * 2 this.ClientRectangle.Bottom - Radius * 2 Radius * 2 Radius * 2 0 90);
graphicsPath.AddArc(this.ClientRectangle.Left this.ClientRectangle.Bottom - Radius * 2 Radius * 2 Radius * 2 90 90);
graphicsPath.CloseFigure();
return graphicsPath;
}
///
/// 获取重绘边框的路径
///
///
private GraphicsPath GetBorderPath()
{
var rec = new Rectangle(ClientRectangle.X + 1 ClientRectangle.Y + 1 ClientRectangle.Width - 2 ClientRectangle.Height - 2);
var graphicsPath = new GraphicsPath();
graphicsPath.StartFigure();
graphicsPath.AddArc(rec.Left rec.Top Radius * 2 Radius * 2 180 90);
graphicsPath.AddArc(rec.
- 上一篇:C#控制系统声音大小
- 下一篇:u3d拖拽旋转缩放模型脚本
相关资源
- 代码编辑器 FastColoredTextBox 智能提示补
- C#自定义可限制输入、可验证信息的
- Wpf Treeview拖拽至Textbox中显示
- C#实现的比较牛逼的语法高亮着色编辑
- 无边框窗体Winform四周阴影效果 C#完美
- c# 自定义TextBox 模糊匹配 百度 谷歌搜
- c#透明textBox,背景可以设置成透明的
- c#简易 数字键盘/手机键盘button控件与
- C#Winform透明Textbox控件
- c# winform RichTextBox Autocomplete 自动完成
- winform 多线程 异步 文件操作(查询、
- RichTextBox Autocomplete 自动完成 智能输入
- Textbox背景透明(winform)
- zw_cwinform用鼠标画拉出来的虚线框鼠标
- C# 字符串多行显示/文本换行以textbo
- c#自定义圆角panel
- C# 文本编辑器之查找和替换功能实现
- C#Winform无边框窗体_最简洁高效功能全
- C#自定义控件---实现带行数和标尺的
- RegexTextBox可验证文本框(.net c# winfo
- TestAutoTextBox.rar
- C#textbox下拉提示 textbox智能提示 te
- wpf border 边框不同颜色
- c# winform 用鼠标画拉出来的虚线框鼠标
- Lx-C#自定义控件---实现带行数和标尺的
- C# TextBox 控件透明
- WPF richtextBox高亮显示指定文本.rar
- WPF自制RichTextBox文本编辑器
- c#实现从Excel导入数据到textbox中
- C# 隐形窗体 (没有边框,没有标题栏
评论
共有 条评论