当前路径:Cool.Windows.Forms/CoolSearchBox.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Drawing.Drawing2D; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Cool.Windows.Forms { public class CoolSearchBox : Control { public CoolSearchBox() { this.DoubleBuffered = true;//设置本窗体 this.SetStyle( //ControlStyles.UserPaint | //使用自定义的绘制方式 ControlStyles.ResizeRedraw//当控件大小发生变化时就重新绘制 | ControlStyles.SupportsTransparentBackColor//则控件接受 alpha 组件数小于 255 个的 BackColor 来模拟透明度 | ControlStyles.AllPaintingInWmPaint//则控件忽略窗口消息 WM_ERASEBKGND 以减少闪烁 | ControlStyles.OptimizedDoubleBuffer//则控件将首先绘制到缓冲区而不是直接绘制到屏幕,这可以减少闪烁 | ControlStyles.DoubleBuffer , true); textBox = new CoolTextBox(); textBox.MouseEnter += TextBox_MouseEnter; textBox.MouseLeave += TextBox_MouseLeave; textBox.Click += TextBox_Click; textBox.LostFocus += TextBox_LostFocus; textBox.GotFocus += TextBox_GotFocus; textBox.BackColor = Color.FromArgb(255, Color.FromArgb(0x374850)); this.Controls.Add(textBox); this.Size = new Size(Padding.Left + textBox.Width + textBox.Height + Padding.Right + Padding.Right, _padding.Top + textBox.Height + _padding.Bottom); textBox.Location = new System.Drawing.Point(_padding.Left, (this.Height - textBox.Height) / 2); textBox.Width = this.Width - _padding.Left * 4 - textBox.Height; searchRect = new Rectangle(_padding.Left + textBox.Width + _padding.Right, (this.Height - textBox.Height) / 2, textBox.Height + 4, textBox.Height + 4); //searchRect.Inflate(4, 4); borderRect.X = textBox.Location.X - _padding.Left / 2; borderRect.Y = textBox.Location.Y - _padding.Top / 2; borderRect.Width = textBox.Width + _padding.Le...
完整源码文件,请先购买后再查看
相关源码
- WINFROM超市管理系统2023-06-07
- 服装管理信息系统2023-06-01
- WPS EXCEL 嵌入 WINFORM2023-05-15
- 仓库管理系统2023-05-14
- WPF基础权限系统2023-05-07
- 资料管理器2023-04-12
关于我们 | 顾问团队 | 发展历程 | 联系我们 | 源码上传
联系电话(Tel):4008-010-151(免长途)
地址:北京市海淀区大恒科技大厦五层 邮编:100080
Floor 5th,Daheng Building,Zhongguancun,Beijing,China,100080
51Aspx.com 版权所有 CopyRight © 2006-2023. 京ICP备09089570号 | 京公网安备11010702000869号
联系电话(Tel):4008-010-151(免长途)
地址:北京市海淀区大恒科技大厦五层 邮编:100080
Floor 5th,Daheng Building,Zhongguancun,Beijing,China,100080
51Aspx.com 版权所有 CopyRight © 2006-2023. 京ICP备09089570号 | 京公网安备11010702000869号