分享

如何改变textBox形状

 牛人的尾巴 2016-03-23
前面看到一个高手写的:
namespace UnderLineBox
{
    public class UnderLineBox : TextBox
    {
        private bool m_underLine;

        public bool UnderLine
        {
            get { return m_underLine; }
            set
            {
                if (this.m_underLine != value)
                {
                    if (value)
                    {
                        this.BorderStyle = BorderStyle.None;
                    }
                    m_underLine = value;
                }
            }
        }
        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);
            if (m.Msg == 0xf || m.Msg == 0x14 || m.Msg == 0x85)
            {
                if (this.BorderStyle == BorderStyle.None)
                {
                    if (m_underLine)
                    {
                        using (Graphics g = Graphics.FromHwnd(this.Handle))
                        {
                            g.DrawLine(SystemPens.ControlText, 0, this.Height - 1, this.Width - 1, this.Height - 1);//这里写你要绘制的形状。
                        }
                    }
                }
            }
        }
    }

}

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约