C#如何去掉ComboBox的下拉按钮

在C#论坛看到有人问,如何让ComboBox下拉按钮只在获取焦点时显示,在那个论坛无法登陆,在这里做下回答protectedoverridevoidWndProc(ref... 在C#论坛看到有人问,如何让ComboBox下拉按钮只在获取焦点时显示,在那个论坛无法登陆,在这里做下回答
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (m.Msg == WM_PAINT)
{ Graphics graphics = Graphics.FromHwnd(this.Handle);
PaintEventArgs pe = new PaintEventArgs(graphics, new Rectangle(0, 0, this.Width, this.Height));
OnPaint(pe); }
}
protected override void OnGotFocus(EventArgs e)
{
base.OnGotFocus(e);
this.Invalidate();
}
protected override void OnLostFocus(EventArgs e)
{
base.OnLostFocus(e);
this.Invalidate();
}

protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
if (!this.Focused)
{
Brush bB = new SolidBrush(this.BackColor);
e.Graphics.FillRectangle(bB, new Rectangle(base.Width - base.Height+1, 1, base.Height-2, base.Height-2));
bB.Dispose();
}
}
重写ComboBox上述方法
展开
 我来答
若以下回答无法解决问题,邀请你更新回答
匿名用户
2009-10-23
展开全部
简单来说就是重画按钮区域
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式