开发者

textbox in winforms with sunken border

How do i set Border properties on a TextBox Control in Winforms so that It displays sunken borders? Any ideas?

Tha开发者_开发技巧nks


Unusual request. But you can do it by selectively disable the theming for the control. Add a new class to your project and paste the code shown below. Compile. Drop the new control from the top of the toolbox onto your form.

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);
}


Just add the Microsoft Forms textbox Control to your toolbox.

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


You need to remove the Application.EnableVisualStyles() call from your Program.cs file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜