Windows窗体中的简单行

编程入门 行业动态 更新时间:2024-10-28 20:31:39
本文介绍了Windows窗体中的简单行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

嘿 如何在Windows窗体中绘制一条简单的线?这张图片中像这样的两行: www.windows7howto/wp-content/uploads/2010/07/Windows-7-Keyboard-Shortcuts.png

Hey How I can draw a simple line in windows form? Something like this 2 lines in this image: www.windows7howto/wp-content/uploads/2010/07/Windows-7-Keyboard-Shortcuts.png

推荐答案

Handle Control.Paint事件(用于控件或表单)或覆盖Control.OnPaint.在这两种情况下,都使用从偶数参数获取的System.Drawing.Graphics实例.使用此实例,使用System.Drawing.Graphics.Draw...方法呈现所需的任何内容. 经OP澄清后: 我的方法将为此工作.您可以使用自定义Control并覆盖OnPaint,或更简单地,仅使用Panel和Paint事件.更改组合键时,请不要忘记:您需要致电Control.Invalidate.而已.会成功的. 替代建议:可能您的图形元素太简单了.尝试在Unicode中找到一些好的字符(使用标准的字符映射"应用程序以查看可用的字符),并仅使用只读的TextBox和其中的文本.对于垂直线,可以使用代码点"|":0x007C :-)或"∣" 0x2223(数学运算-除法"甚至是│" 0x2502或┃" 0x2503(箱形图,轻垂直/重垂直). 为什么使事情变得比其复杂?
—SA
Handle Control.Paint event (for a control or a form) or override Control.OnPaint. In both cases, use System.Drawing.Graphics instance obtained from even argument. Using this instance, use System.Drawing.Graphics.Draw... methods to render whatever you want. After clarification by OP: My method will work for this. You can use custom Control and override OnPaint or, more simply, use just Panel and Paint event. When you change the key combination, don''t forget: you need to call Control.Invalidate. That''s it. It will do the trick. Alternative suggestion: may be you graphical element is too simple. Try to find some good character in Unicode (use standard "Character Map" application to see what''s available) and use just a read-only TextBox and just text in it. For a vertical line, you can use code point ''|'': 0x007C :-) or ''∣'' 0x2223 (Mathematical Operations — "Divides" or even ''│'' 0x2502 or ''┃'' 0x2503 (Box Drawing, Light Vertical / Heavy Vertical). Why making things more complex than they can be?
—SA

您还可以考虑使用各种形状控件: .NET的形状控制 [ ^ ] 高级形状控制 [ ^ ] 或者,如果您想做一些真正想做的事情,请看以下内容: .NET的Sprite编辑器 [ ^ ]. 您可以使用sprites覆盖表单,如先前文章中所示: FormSprite:我爱你杰西卡! [ ^ ] 问候 Espen Harlinn You could also consider the various shape controls available: Shape Control for .NET[^] Advanced Shape Control[^] Or if you want to do something really fancy - take a look at: Sprite Editor for .NET[^]. You can overlay your forms with sprites as is shown in an earlier article: FormSprite: I Love You Jessica![^] Regards Espen Harlinn

更多推荐

Windows窗体中的简单行

本文发布于:2023-06-03 05:44:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/466291.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:窗体   简单   Windows

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!