使用Windows窗体TextBox时,默认的制表位数(空格)为8.如何修改?
答案 0 :(得分:4)
首先添加以下命名空间
using System.Runtime.InteropServices;
然后在类声明后添加以下内容:
private const int EM_SETTABSTOPS = 0x00CB;
[DllImport("User32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr SendMessage(IntPtr h,
int msg,
int wParam,
int [] lParam);
然后将以下内容添加到Form_Load事件:
// define value of the Tab indent
int[] stops = {16};
// change the indent
SendMessage(this.textBox1.Handle, EM_SETTABSTOPS, 1, stops);