可移动矩形或标签
我正在 Visual C# 2010 中编写一个程序,该程序在窗体上有多个图标。当鼠标放在图标(只是一个图像)上时,我希望通过图标周围的边框突出显示该图标。在 Visual Basic 中,我可以制作一个带有彩色边框的透明矩形,并将其放置在图标上。在 C# 中,我可以执行相同的操作,直到我调用使多个边框无效。调用 invalidate 的问题是我的程序每秒都在后台执行某些操作,因此边框不断闪烁(重新绘制)。
有人对我如何实现这个有任何想法吗?
I am writing a program in Visual C# 2010 that has several icons on the form. When the mouse is placed over the icon (which is just an image) I want the icon to b highlighted via a border around the icon. In visual basic i can make a transparent rectangle with a colored border and position it over the icon. In C#, i can do the same however until i call invalidate multiple borders appear. The problem with calling invalidate is that my program is doing something in the background every second so the border keeps flashing (re-drawing).
Anyone got any ideas how i can implement this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您没有说如何绘制边框,但根据您的描述,您正在为此创建图形上下文。不要这样做,这是错误的。相反,请在控件或其父容器的
Paint
元素内进行绘制。画图
事件处理程序可能如下所示:这使用假设的
HasFocus
方法来确定此控件是否应具有焦点矩形。顺便说一句,这在 VB 和 C# 中是相同的。
You didn’t say how you draw the border but from your description you are creating a graphics context for this. Don’t do this, it’s wrong. Instead, draw inside the
Paint
element of either the control or the its parent container.The
Paint
event handler could look as follows:This uses a hypothetical
HasFocus
method to determine whether this control should have a focus rectangle.By the way, this is identical in VB and C#.