[DllImport("user32.dll")]
private static extern int SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam, IntPtr lParam);
private void SetTabStops(System.Windows.Forms.TextBox textBox, int[] tabStops)
{
const int EM_SETTABSTOPS = 0xCB;
GCHandle gcHandle = GCHandle.Alloc(tabStops, GCHandleType.Pinned);
IntPtr ptr = gcHandle.AddrOfPinnedObject();
SendMessage(textBox.Handle, EM_SETTABSTOPS, new IntPtr(tabStops.Length), ptr);
gcHandle.Free();
textBox.Refresh();
}
private unsafe void MainMethod()
{
string[] lines = new[]
{
"One\tTwo\tThree",
"Item1\tItem2\tItem3",
"Something1\tSomething2\tSomething3"
};
textBox2.Lines = lines;
SetTabStops(textBox2, new[] {75, 150});
}