急!!!怎么更改textBox边框的颜色啊 急!!!怎么更改textBox边框的颜色啊 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 WebForm OR WinForm?/WebForm: 用styleWinForm: override OnPaint,自己画边框 设置BorderStyle = BorderStyle.None自己再画一个有颜色的边框 表示文本框控件边框类型的 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"/> 如果是 WINFORM, 请参见:http://community.csdn.net/Expert/topic/4149/4149498.xml .txtBox{ font-size: 8pt; font-family: Verdana; width: 100%; height: 19px; border: 1px solid #7b9ebd; vertical-align: middle; } CssClass=txtBox小山的应该可以。 继承System.Windows.Forms.Text,重写OnPaint事件 顺便说句,WinApp不是时装设计舞台,牛逼到天上的界面风格只能挨骂的几率很大。其实重要的是大方得体整齐方便。有个简单的衡量标准是如果你在国际大公司的主流软件中尤其是在微软的软件里,如果看不见和你的类似设计,即使你觉得自己的想法很好,即使你有一万个理由,别犹豫,否定掉自己的设计吧。那些大公司聘请的专业界面师水平太菜?你的设计实在惊天地泣鬼神到无人能及地步?还是愿意相信这是你一相情愿的设计?软件的界面是要给别人更好地使用,需要别人认可你才有用,自己觉得好看没用。 自定义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(.........)截一个图片也是可以的。本人已做好大部分已经美化的控件。 感谢sureit(rasen) 的提示我很想看看你做的控件,能否发一个给我[email protected] 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等是颜色 在默认情况下继承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); } } http://community.csdn.net/Expert/topic/4149/4149498.xml 紧急求助,关于OleDbDataAdapter进行删除数据的问题? sqlserver2000运行时右下角出现的小图标,在2005下怎么样才能出现? 获取焦点 获取百度网页源码问题 如何在自动生成的word文档中加入水印? 求助,如何将checkbox加在treeview最后一个节点上 请教关于XML的问题!! 制作邮件发送的问题 求教高手:如何打包C#的WINDOWS应用? 请问:在C#中,如何将数学表达式的字符串进行数学运算,例如: 请问在WinFrom(C#)中,能否实现将鼠标的活动范围限定在某一个窗体之内的功能。 在c#下如何实现类似MFC中HitTest的功能?
WinForm: override OnPaint,自己画边框
BorderStyle = BorderStyle.None
自己再画一个有颜色的边框
<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"/>
http://community.csdn.net/Expert/topic/4149/4149498.xml
{
font-size: 8pt;
font-family: Verdana;
width: 100%;
height: 19px;
border: 1px solid #7b9ebd;
vertical-align: middle;
}
小山的应该可以。
protected override void OnPaint(PaintEventArgs e)
{
DrawBorder();
}private void DrawBorder(Graphics g, int x, int y, int width, int height)
{
g.DrawRectangle(.);
}
只是想画有个一个框的话,g.DrawImage(.........)截一个图片也是可以的。
本人已做好大部分已经美化的控件。
我很想看看你做的控件,能否发一个给我[email protected]
{
//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等是颜色
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);
} }