如何设置combobox边框颜色

liuchenglin_lcl 2008-12-01 05:58:29
刚刚接触C/S项目,请高手给于指点
...全文
1170 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
qp0002 2011-10-30
  • 打赏
  • 举报
回复
看看怎么弄
jxxlsoft 2010-05-20
  • 打赏
  • 举报
回复
看看怎么弄
gamesky200808 2009-09-09
  • 打赏
  • 举报
回复
看看怎么弄
abcniu 2008-12-02
  • 打赏
  • 举报
回复
学习学习
leo_bogard 2008-12-02
  • 打赏
  • 举报
回复
up
dayizhixiaotutu 2008-12-02
  • 打赏
  • 举报
回复
public class ComboBoxDraw : ComboBox
{
private System.Drawing.Color m_BorderColorOut;
private System.Windows.Forms.ButtonBorderStyle m_BorderColorStyle;

public ComboBoxDraw()
{
m_BorderColorOut = System.Drawing.Color.FromArgb(((int)(((byte)(57)))), ((int)(((byte)(130)))), ((int)(((byte)(180)))));
BorderColorStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
}

public System.Drawing.Color BorderColorOut
{
get
{
return this.m_BorderColorOut;
}
set
{
this.m_BorderColorOut = value;
//在该值发生变化时重绘控件,下同
//在设计模式下,更改该属性时,如果不调用该语句,
//则不能立即看到设计试图中该控件相应的变化
this.DrawBorder();
}
}
public System.Windows.Forms.ButtonBorderStyle BorderColorStyle
{
get
{
return this.m_BorderColorStyle;
}
set
{
this.m_BorderColorStyle = value;
//在该值发生变化时重绘控件,下同
//在设计模式下,更改该属性时,如果不调用该语句,
//则不能立即看到设计试图中该控件相应的变化
this.DrawBorder();
}
}
protected override void WndProc(ref System.Windows.Forms.Message m)
{
base.WndProc(ref m);

//拦截系统消息,获得当前控件进程以便重绘。
if (m.Msg == 0xf || m.Msg == 0x133)
{
this.DrawBorder();
}
}
private void DrawBorder()
{
System.Windows.Forms.ControlPaint.DrawBorder(this.CreateGraphics(), new System.Drawing.Rectangle(0, 0, this.Width, this.Height), this.m_BorderColorOut, this.m_BorderColorStyle);
}
}
sunnyhuang2008 2008-12-02
  • 打赏
  • 举报
回复
up
liuchenglin_lcl 2008-12-02
  • 打赏
  • 举报
回复
4楼的给说的详细一点呀
liang4571231 2008-12-02
  • 打赏
  • 举报
回复
顶顶
销魂的拖拉机 2008-12-02
  • 打赏
  • 举报
回复
下拉用drawitem
goldxinx 2008-12-01
  • 打赏
  • 举报
回复
重写combobox
liuchenglin_lcl 2008-12-01
  • 打赏
  • 举报
回复
谢谢
lijunfeng 2008-12-01
  • 打赏
  • 举报
回复
用的多的话继承combobox自己用GDI+画边框
用的不多的话有两个笨方法:
一:将combobox的FlatStyle设为Flat,在上级容器(如Form)的Paint事件里用GDI+按combobox的位置和大小画框框
二:放四个label分为将高或宽设为1,背景色设成你想要的,放在combobox四周

110,534

社区成员

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

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

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