How to change the TreeView nods alignment to right-to-left?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • abbas roshande
    New Member
    • Feb 2011
    • 1

    How to change the TreeView nods alignment to right-to-left?

    Hi guys,

    I am using MS Access VBA and could download a sample TreeView which is nice. I only need to change the nods and childs alignment to right-to-left. (My Language is Persian)

    I appreciate your kind help.
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    I do believe that there is no way to right-align Nodes in a treeView Control. What you can do is to experiment with the Indentation Property of the TreeView Control as in:
    Code:
    Me![TreeView1].Indentation = 1000

    Comment

    • stabesh
      New Member
      • May 2010
      • 4

      #3
      Hi
      Create a module and declare the following APIs
      Code:
      Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
      Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
      Public Declare Function InvalidateRect Lib "user32" (ByVal hwnd As Long, lpRect As Long, ByVal bErase As Long) As Long
      Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
      Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
      Public Const GW_CHILD = 5
      Public Const WS_EX_LAYOUTRTL = &H400000
      Public Const GWL_EXSTYLE = (-20)
      At the form load add the mirroring effect as follows
      Code:
      Private Sub Form_Load() 'On Form Load you need to set 
          Dim OldLong As Long
          'For TreeView
          Dim nodX As Node
          Set nodX = TreeView1.Nodes.Add(, , "R", "Root")
          Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C1", "Child 1")
          Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C2", "Child 2")
          Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C3", "Child 3")
          Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C4", "Child 4")
          nodX.EnsureVisible
          OldLong = GetWindowLong(TreeView1.hwnd, GWL_EXSTYLE)
          SetWindowLong TreeView1.hwnd, GWL_EXSTYLE, OldLong Or WS_EX_LAYOUTRTL
          InvalidateRect hwnd, 0, False
      End Sub
      Explore Microsoft products and services for your home or business. Shop Microsoft 365, Copilot, Teams, Xbox, Windows, Azure, Surface and more.

      Comment

      Working...