Post by "rickey ", 08-24-2007, 9:17
-----------------------------------------------------
我知道用System.Windows.Forms.ComboBoxRender.DrawTextBox()可以绘制出一个TextBox的效果,但我只需要边框就OK了,不知道哪位大虾支点招?
另外,使用 System.Windows.Forms.VisualStyles.VisualStyleRenderer.DrawEdge()是否可以?
Reply by "J2.NETe", 08-24-2007, 9:37
-----------------------------------------------------
自己用线拼~~~ControlPaint
如果要画CheckBox或者RadioButton可以用字符拼~~那些字符在“Marlett”字体中~~
may you bask in the glory of light.
Reply by "ted", 08-24-2007, 9:59
-----------------------------------------------------
不知楼主所讲的“类似VS2005中TextBox的边框效果”指的是下面的那一种边框, 或者别的样子:
1 means highlight effect, 2 is normal border, and 3 is vista text box border.
Reply by "rickey", 08-27-2007, 9:16
-----------------------------------------------------
类似于楼上的第3种框架.
但是使用ComboBoxRender.DrawTextbox()绘制的时候,不仅绘制了边框,还填充了TextBox;而我只想要绘制边框就可以了;
找了两天,还是没找到合适的接口,郁闷...
Reply by "ted", 08-27-2007, 10:28
-----------------------------------------------------
- public class MyControl : Control
- {
- protected override void OnPaint(PaintEventArgs e)
- {
- base.OnPaint(e);
- if (VisualStyleRenderer.IsSupported)
- {
- VisualStyleRenderer render = new VisualStyleRenderer(VisualStyleElement.TextBox.TextEdit.Normal);
- render.DrawBackground(e.Graphics, new Rectangle(10, 10, 50, 50));
- }
- ControlPaint.DrawVisualStyleBorder(e.Graphics, new Rectangle(70, 70, 50, 50));
- }
- }
复制代码 Please have a try, and seems the second method is proper for you.
Reply by "rickey", 08-27-2007, 20:54
-----------------------------------------------------
问题已经解决,非常感谢TED的热心帮助。
顺便问一下,ControlPaint.DrawVisualStyleBorder()方法是3.0中新增的方法吗?
Reply by "lalac", 08-30-2007, 9:41
-----------------------------------------------------
ControlPaint.DrawVisualStyleBorder() 是DotNET2.0提供的新方法。
- // Refector from System.Windows.Forms.dll
- public static void DrawVisualStyleBorder(Graphics graphics, Rectangle bounds)
- {
- if (graphics == null)
- {
- throw new ArgumentNullException("graphics");
- }
- using (Pen pen = new Pen(VisualStyleInformation.TextControlBorder))
- {
- graphics.DrawRectangle(pen, bounds);
- }
- }
复制代码 |
|