带有凹陷边界的winforms中的文本框

时间:2010-03-17 21:21:49

标签: winforms

如何在Winforms中的TextBox控件上设置Border属性,以便它显示凹陷的边框? 有什么想法吗?

由于

3 个答案:

答案 0 :(得分:1)

只需将Microsoft Forms文本框控件添加到工具箱中即可。

alt text http://img262.imageshack.us/img262/2989/28550946.png

答案 1 :(得分: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);
}

答案 2 :(得分:0)

您需要从Program.cs文件中删除Application.EnableVisualStyles()调用。