devxlogo

Toggle Listview Headers Between Flat and 3-D

Toggle Listview Headers Between Flat and 3-D

Whenever you want a ListView control with flat, nonclickable headers, use this code to toggle the header style. Flat headers don’t give users the impression of sortability that 3-D headers do:

 Private Declare Function GetWindowLong Lib _	"user32" Alias "GetWindowLongA" (ByVal hWnd _	As Long, ByVal nIndex As Long) As LongPrivate Declare Function SetWindowLong Lib _	"user32" Alias "SetWindowLongA" (ByVal hWnd _	As Long, ByVal nIndex As Long, ByVal _	dwNewLong As Long) As LongPrivate Const GWL_STYLE = (-16)Private Const LVM_FIRST = &H1000Private Const LVM_GETHEADER = (LVM_FIRST + 31)Private Const HDS_BUTTONS = &H2Call ToggleHeader(ListView1.hWnd)Private Sub ToggleHeader(lsvhWnd As Long)	Dim hHeader As Long, lStyle As Long	hHeader = SendMessage(lsvhWnd, _		LVM_GETHEADER, 0, ByVal 0&)	lStyle = GetWindowLong(hHeader, GWL_STYLE)	SetWindowLong hHeader, GWL_STYLE, lStyle Xor _		HDS_BUTTONSEnd Sub
See also  How HealthStream Learning Center Supports Healthcare Education and Compliance
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist