急!!!怎么更改textBox边框的颜色啊

解决方案 »

  1.   

    WebForm OR WinForm?/WebForm: 用style
    WinForm: override OnPaint,自己画边框
      

  2.   

    设置
    BorderStyle = BorderStyle.None
    自己再画一个有颜色的边框
      

  3.   

    表示文本框控件边框类型的 BorderStyle。
    <asp:TextBox id="value"
         AutoPostBack="True|False"
         Columns="characters"
         MaxLength="characters"
         Rows="rows"
         Text="text"
         TextMode="SingleLine | MultiLine | Password"
         Wrap="True|False"
         OnTextChanged="OnTextChangedMethod"
         runat="server"/>
      

  4.   

    如果是 WINFORM, 请参见:
    http://community.csdn.net/Expert/topic/4149/4149498.xml
      

  5.   

    .txtBox
    {
    font-size: 8pt;
    font-family: Verdana;
    width: 100%;
    height: 19px;
    border: 1px solid #7b9ebd;
    vertical-align: middle; 
    }
      

  6.   

    CssClass=txtBox
    小山的应该可以。
      

  7.   

    继承System.Windows.Forms.Text,重写OnPaint事件
      

  8.   

    顺便说句,WinApp不是时装设计舞台,牛逼到天上的界面风格只能挨骂的几率很大。其实重要的是大方得体整齐方便。有个简单的衡量标准是如果你在国际大公司的主流软件中尤其是在微软的软件里,如果看不见和你的类似设计,即使你觉得自己的想法很好,即使你有一万个理由,别犹豫,否定掉自己的设计吧。那些大公司聘请的专业界面师水平太菜?你的设计实在惊天地泣鬼神到无人能及地步?还是愿意相信这是你一相情愿的设计?软件的界面是要给别人更好地使用,需要别人认可你才有用,自己觉得好看没用。
      

  9.   

    自定义TextBox控件
    protected override void OnPaint(PaintEventArgs e)
    {
       DrawBorder();
    }private  void DrawBorder(Graphics g, int x, int y, int width, int height)
    {
       g.DrawRectangle(.);
    }
    只是想画有个一个框的话,g.DrawImage(.........)截一个图片也是可以的。
    本人已做好大部分已经美化的控件。
      

  10.   

    感谢sureit(rasen) 的提示
    我很想看看你做的控件,能否发一个给我[email protected]
      

  11.   

    sorry 本人几乎不发邮件。现在给出一个groupbox自定义控件,其它的自己多想想,举一反三。protected override void OnPaint(PaintEventArgs e)
    {
    //base.OnPaint (e);
    Graphics g = e.Graphics;
    Size szText = g.MeasureString(this.Text, this.Font).ToSize();
    int cyAdjust = szText.Height / 2;
    Rectangle rc = new Rectangle(0, cyAdjust, this.Width - 1, this.Height - cyAdjust - 1);
    DrawRoundedRectangle(g, new Pen(bordColor, 0), rc, szIndent);
    g.FillRectangle(new SolidBrush(this.BackColor), 7, 0, szText.Width - 1, szText.Height);
    Color clrText = this.ForeColor;
    if (this.Enabled)
    {
    if (clrText == SystemColors.ControlText)
    clrText = Color.FromArgb(0, 70, 213);
    Rectangle BGrect = new Rectangle(1,1,this.Width -2,this.Height - 3);
    DrawBGColor(g,bgColor1,bgColor2,BGrect);
    }
    else
    {
    clrText = DisabledForeColor;
    } g.DrawString(this.Text, this.Font, new SolidBrush(clrText), 7, 0);
    }private  void DrawRoundedRectangle(Graphics g, Pen p, Rectangle rc, Size size)
    {
    // 1 pixel indent in all sides = Size(4, 4)
    // To make pixel indentation larger, change by a factor of 4,
    // i. e., 2 pixels indent = Size(8, 8); SmoothingMode oldSmoothingMode = g.SmoothingMode;
    g.SmoothingMode = SmoothingMode.AntiAlias;

    g.DrawLine(p, rc.Left  + size.Width / 2, rc.Top,
    rc.Right - size.Width / 2, rc.Top);
    g.DrawArc(p, rc.Right - size.Width, rc.Top,
    size.Width, size.Height, 270, 90); g.DrawLine(p, rc.Right, rc.Top + size.Height / 2,
    rc.Right, rc.Bottom - size.Height / 2);
    g.DrawArc(p, rc.Right - size.Width, rc.Bottom - size.Height,
    size.Width, size.Height, 0, 90); g.DrawLine(p, rc.Right - size.Width / 2, rc.Bottom,
    rc.Left  + size.Width / 2, rc.Bottom);
    g.DrawArc(p, rc.Left, rc.Bottom - size.Height, 
    size.Width, size.Height, 90, 90); g.DrawLine(p, rc.Left, rc.Bottom - size.Height / 2,
    rc.Left, rc.Top + size.Height / 2);
    g.DrawArc(p, rc.Left, rc.Top,
    size.Width, size.Height, 180, 90); g.SmoothingMode = oldSmoothingMode;
    }private void DrawBGColor(Graphics g,Color color1,Color color2,Rectangle rect)
    {
     LinearGradientBrush br = new LinearGradientBrush(rect,color1,color2,LinearGradientMode.ForwardDiagonal);
    g.FillRectangle(br,rect);
    }
    color1等是颜色
      

  12.   

    在默认情况下继承TextBox的控件,OnPaint是不会响应的,必须这样
    public class MyTextBox : System.Windows.Forms.TextBox 
    {
    public MyTextBox()
    {
    SetStyle(ControlStyles.UserPaint, true);
    } protected override void OnPaint(PaintEventArgs e)
    {
    base.OnPaint(e);
    e.Graphics.Clear(System.Drawing.Color.Red);
    } }
      

  13.   

    http://community.csdn.net/Expert/topic/4149/4149498.xml