2008-09-09 62 views
1

當您使用Windows窗體文本框時,默認數量的製表位(空格)是8.如何修改此?如何修改文本框控件選項卡停止

+0

做工精細,但你忘了說'對話框模板單位'中測量的值(不管它們是什麼)。 `int [] = {16}`用我的字體給出一個包含四個空格的標籤。 – 2010-11-26 21:05:10

回答

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); 
相關問題