2010-03-17 68 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); 
}