2010-03-17 67 views
0

如何在Winforms中的TextBox控件上设置边框属性,以便它显示下陷的边框? 任何想法?带有下陷边框的Winforms中的文本框

谢谢

+0

是不是默认的?你希望它看起来像这个链接中的示例'Form3':http://www.startvbdotnet.com/controls/textbox.aspx – northpole 2010-03-17 21:25:54

回答

0

您需要从您的Program.cs文件中删除Application.EnableVisualStyles()电话。

+0

似乎不工作...我需要做额外的事情吗? '编辑':现在工作....更改是可见的,直到你运行你的应用程序。 – Luiscencio 2010-03-17 21:34:56

1

不寻常的要求。但是,您可以通过选择性地禁用控制主题来实现。为您的项目添加一个新类并粘贴下面显示的代码。编译。将新的控件从工具箱的顶部拖放到表单上。

using System; 
using System.Windows.Forms; 

class SunkenTextBox : TextBox { 
    protected override void CreateHandle() { 
    base.CreateHandle(); 
    SetWindowTheme(this.Handle, "", ""); 
    } 
    [System.Runtime.InteropServices.DllImport("uxtheme.dll")] 
    private static extern void SetWindowTheme(IntPtr hWnd, string appname, string idlist); 
}