CustomTextBox: Añadir parámetro para especificar anchura del tabulador.

This commit is contained in:
2013-11-24 03:50:48 +01:00
parent 114db3ae7f
commit 26384b9975
6 changed files with 55 additions and 12 deletions

View File

@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace ServerExplorer.Controls
{
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.AutoDispatch)]
public class CustomTextBox : TextBox
{
#region SetTabWidth
private const int EM_SETTABSTOPS = 0x00CB;
[DllImport("User32.dll", CharSet = CharSet.Auto)]
private static extern IntPtr SendMessage(IntPtr h, int msg, int wParam, int[] lParam);
public void SetTabWidth(int tabWidth)
{
SendMessage(this.Handle, EM_SETTABSTOPS, 1, new int[] { tabWidth * 4 });
}
#endregion
private int _tabWidth=8;
public int TabWidth
{
get { return _tabWidth; }
set
{
_tabWidth = value;
SetTabWidth(value);
}
}
}
}