Question : How do you change the tab stops for a text box in VB.NET 2010?

How do you change the tab stops for a text box in VB.NET 2010?

By default, they are set to every 8 characters.

If my text box is called TextBox1, how do I tell Windows that the tab stops should be every 4 characters instead of 8?

My text box has "AcceptsTab" and "AcceptsReturn" set to true.

Thanks.

Answer : How do you change the tab stops for a text box in VB.NET 2010?

Try this

Public Class Form1
      Private Declare Function SendMessage _
       Lib "user32" Alias "SendMessageA" _
       (ByVal handle As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByRef lParam As Integer) As Integer
      Const EM_SETTABSTOPS = &HCB

      Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim tabsSize() As Integer = {16, 32, 48}            ' 4*pos
            SendMessage(TextBox1.Handle, EM_SETTABSTOPS, tabsSize.Length, tabsSize(0))
      End Sub

End Class
Random Solutions  
 
programming4us programming4us