本帖最后由 icelovey 于 2013-10-26 19:51:08 编辑

解决方案 »

  1.   

    可以自己自定义一个控件,以后的项目直接拖动这个控件到窗体即可。
     public partial class CustomControl1 : TextBox
        {
            public CustomControl1()
            {
                InitializeComponent();            this.BorderStyle = BorderStyle.None;
                this.BackColor = SystemColors.Control;
            }        private int WM_PAINT = 0x000F;
            protected override void WndProc(ref Message m)
            {
                base.WndProc(ref m);            if (m.Msg == WM_PAINT)
                {
                    Pen pen = new Pen(Brushes.Olive, 1.5f);
                    using (Graphics g = this.CreateGraphics())
                    {
                        g.DrawLine(pen, new Point(0, this.Size.Height - 1), new Point(this.Size.Width, this.Size.Height - 1));
                    }
                }
            }
        }
      

  2.   


    已经是自动定义的控件, 写法就是类似你的, 但是出现上面的问题
    就是在用户切换到其他程序, 程序并没有最小化,   比如EXCEL, OUTLOOK等的时候, 那个线仍然显示出来, 影响到用户不能很好的使用EXCEL等程序, 最小化的时候, 那个线是会消失的. 
      

  3.   

    我在win8系统下测试了一下,好像并没有你说的这个问题。
      

  4.   

    主要程序很多用户, 有些是XP, 有些是WIN7, 而且配置不一, 出现这个问题也不是说每次,  有没有办法在程序不在最前的时候, 怎么强制刷新一下? 比如新建个线程, 随时检测是不是在最前, 让横线消失, 刚学C# 不是很懂
      

  5.   

    用一个无边框的文本框加一个高度只有1或2的label不可以实现吗?把label的text输成_________
      

  6.   

    或者把label的背景色改为黑色