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

zyspp 2005-08-16 09:33:35
急!!!怎么更改textBox边框的颜色啊
...全文
1318 19 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
cdo 2005-08-29
  • 打赏
  • 举报
回复
http://community.csdn.net/Expert/topic/4149/4149498.xml
pupo 2005-08-29
  • 打赏
  • 举报
回复
在默认情况下继承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);
}

}
木梓油 2005-08-29
  • 打赏
  • 举报
回复
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等是颜色
木梓油 2005-08-28
  • 打赏
  • 举报
回复
自定义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(.........)截一个图片也是可以的。
本人已做好大部分已经美化的控件。

syeerzy 2005-08-28
  • 打赏
  • 举报
回复
顺便说句,WinApp不是时装设计舞台,牛逼到天上的界面风格只能挨骂的几率很大。其实重要的是大方得体整齐方便。

有个简单的衡量标准是如果你在国际大公司的主流软件中尤其是在微软的软件里,如果看不见和你的类似设计,即使你觉得自己的想法很好,即使你有一万个理由,别犹豫,否定掉自己的设计吧。

那些大公司聘请的专业界面师水平太菜?你的设计实在惊天地泣鬼神到无人能及地步?还是愿意相信这是你一相情愿的设计?

软件的界面是要给别人更好地使用,需要别人认可你才有用,自己觉得好看没用。
syeerzy 2005-08-28
  • 打赏
  • 举报
回复
如果急用,下载个皮肤控件顶着先,如果不是,自己实现的话在2003是麻烦点了,自己重绘吧。
zyspp 2005-08-28
  • 打赏
  • 举报
回复
感谢sureit(rasen) 的提示
我很想看看你做的控件,能否发一个给我zyspipi@163.com
salmon230 2005-08-28
  • 打赏
  • 举报
回复
学习
zyspp 2005-08-28
  • 打赏
  • 举报
回复
能给个例子吗
zhgroup 2005-08-27
  • 打赏
  • 举报
回复
继承System.Windows.Forms.Text,重写OnPaint事件
zyspp 2005-08-27
  • 打赏
  • 举报
回复
没人能回答了吗
zyspp 2005-08-18
  • 打赏
  • 举报
回复
我要的是WINFORM的
Allison 2005-08-17
  • 打赏
  • 举报
回复
学习了
longhorn008 2005-08-16
  • 打赏
  • 举报
回复
CssClass=txtBox
小山的应该可以。
singlepine 2005-08-16
  • 打赏
  • 举报
回复
.txtBox
{
font-size: 8pt;
font-family: Verdana;
width: 100%;
height: 19px;
border: 1px solid #7b9ebd;
vertical-align: middle;
}
wuyi8808 2005-08-16
  • 打赏
  • 举报
回复
如果是 WINFORM, 请参见:
http://community.csdn.net/Expert/topic/4149/4149498.xml
wsh236 2005-08-16
  • 打赏
  • 举报
回复
表示文本框控件边框类型的 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"/>
不务正 2005-08-16
  • 打赏
  • 举报
回复
设置
BorderStyle = BorderStyle.None
自己再画一个有颜色的边框
TechEye 2005-08-16
  • 打赏
  • 举报
回复
WebForm OR WinForm?/

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

111,094

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧