Sign in to follow this  
Followers 0
Achilles

Listviews: centered item text but left aligned header text

3 posts in this topic

This is what I've tried... I want the subitems to be centered but the header to be left aligned:

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>

GUICreate("ListView Set Column", 400, 300)
$hListView = GUICtrlCreateListView("", 2, 2, 394, 268)
$hListViewHeader = _GUICtrlListView_GetHeader(GUICtrlGetHandle($hListView))


; Add columns
_GUICtrlListView_AddColumn($hListView, "Column 1", 100)
_GUICtrlListView_AddColumn($hListView, "Column 2", 100)
_GUICtrlListView_AddColumn($hListView, "Column 3", 100)
GUICtrlCreateListViewItem('a|b|c', $hListView)


; Change column
$aInfo = _GUICtrlListView_GetColumn($hListView, 0)

_GUICtrlListView_SetColumn($hListView, 0, "New Column 1", 150, 2)

_GUICtrlHeader_SetItemAlign($hListViewHeader, 0, 1)

GUISetState()

; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites



Simple trick:

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>

GUICreate("ListView Set Column", 400, 300)
$hListView = GUICtrlCreateListView("", 2, 2, 394, 268)
$hListViewHeader = _GUICtrlListView_GetHeader(GUICtrlGetHandle($hListView))

; Add columns
_GUICtrlListView_AddColumn($hListView, "Column 1", 100)
_GUICtrlListView_AddColumn($hListView, "Column 2", 100)
_GUICtrlListView_AddColumn($hListView, "Column 3", 100)

GUICtrlCreateListViewItem('a|           b|           c', $hListView)

; Change column
$aInfo = _GUICtrlListView_GetColumn($hListView, 0)

_GUICtrlListView_SetColumn($hListView, 0, "New Column 1", 150, 2)

GUISetState()

; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()

:P

Share this post


Link to post
Share on other sites

Simple trick:

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>

GUICreate("ListView Set Column", 400, 300)
$hListView = GUICtrlCreateListView("", 2, 2, 394, 268)
$hListViewHeader = _GUICtrlListView_GetHeader(GUICtrlGetHandle($hListView))

; Add columns
_GUICtrlListView_AddColumn($hListView, "Column 1", 100)
_GUICtrlListView_AddColumn($hListView, "Column 2", 100)
_GUICtrlListView_AddColumn($hListView, "Column 3", 100)

GUICtrlCreateListViewItem('a|           b|           c', $hListView)

; Change column
$aInfo = _GUICtrlListView_GetColumn($hListView, 0)

_GUICtrlListView_SetColumn($hListView, 0, "New Column 1", 150, 2)

GUISetState()

; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()

:P

That doesn't work if the user resizes the columns which they'll be able to do in this program. I thought there might be a way of applying a setting only to the header of the listview and not all of it...

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0