1、不要更改属性的那种方法
2、直接加载页面就显示为横线
3、调试成功立即结帖
4、分数只给代码最优者

解决方案 »

  1.   

    using System.Windows.Forms;public class Test : Form
    {
      Test()
      {
        TextBox tbx = new TextBox();
        tbx.Parent  = this;
        tbx.Multiline = true;
        tbx.Top = 50;
        tbx.Height = 1;
      }  static void Main()
      {
        Application.Run(new Test());
      }
    }
      

  2.   

    用 Label 效果更好:using System.Windows.Forms;public class Test : Form
    {
      Test()
      {
        Label lbl = new Label();
        lbl.Parent  = this;
        lbl.BorderStyle = BorderStyle.Fixed3D;
        lbl.Anchor |= AnchorStyles.Right;
        lbl.Top = 50;
        lbl.Width = Width;
        lbl.Height = 3;
      }  static void Main()
      {
        Application.Run(new Test());
      }
    }
      

  3.   

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Drawing;
    using System.Data;
    using System.Text;
    using System.Windows.Forms;namespace JcsControlLibrary
    {
        public partial class JcsLineTextBox : TextBox 
        {
            public JcsLineTextBox()
            {
                InitializeComponent();
                this.Width = 100;
                this.BorderStyle = BorderStyle.None;
            }
            private Color _linecolor = Color.Black ;
            /// <summary>
            /// 线条颜色
            /// </summary>
            public Color LineColor
            {
                get
                {
                    return this._linecolor;
                }
                set
                {
                    this._linecolor = value;
                    this.Invalidate();
                }
            }
            private const int WM_PAINT = 0xF;
            protected override void WndProc(ref Message m)
            {
                base.WndProc(ref m);
                if (m.Msg == WM_PAINT)
                {
                    DrawLine();
                }
            }
            private void DrawLine()
            {
                Graphics g = this.CreateGraphics();
                using(Pen p = new Pen(this._linecolor ))
                {
                    g.DrawLine(p,0,this.Height -1 ,this.Width ,this.Height -1);
                }
            }
        }
    }
      

  4.   

    TO:chenxu4277
       很感谢你的回复,但是没有实现…
        所定义的自定义类JcsLineTextBox在主窗体怎么实现?
        把你的代码在VS2008下运行时没有效果…
      

  5.   

    不知LZ是什么意思,要达到什么效果。难道是这样:using System.Windows.Forms;class TextBox : System.Windows.Forms.TextBox
    {
      public TextBox()
      {
        Multiline = true;
        Height    = 1;
      }
    }class Test : Form
    {
      Test()
      {
        TextBox tbx1 = new TextBox();
        tbx1.Parent  = this;    TextBox tbx2 = new TextBox();
        tbx2.Parent  = this;
        tbx2.Top     = 50;    TextBox tbx3 = new TextBox();
        tbx3.Parent  = this;
        tbx3.Top     = 50;
        tbx3.Left    = 150;
      }  static void Main()
      {
        Application.Run(new Test());
      }
    }
      

  6.   

    TO EveryOne:
       非常感谢大家的回答,本问题已由chenxu4277圆满解决
        现在结帖…
      

  7.   

    chenxu4277 重写控件 牛啊