# ListBox Header Align

**URL:** <https://forum.xojo.com/t/listbox-header-align/68087>\
**Category:** Targets\
**Created:** [January 20, 2022, 12:39pm UTC](https://forum.xojo.com/t/listbox-header-align/68087 "2022-01-20T12:39:21Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sebastien\_REMY](https://forum.xojo.com/user_avatar/forum.xojo.com/sebastien_remy/32/1946_2.png) [@Sebastien\_REMY](https://forum.xojo.com/u/Sebastien_REMY)\
**Post date:** [January 20, 2022, 12:39pm UTC](https://forum.xojo.com/t/listbox-header-align/68087/1 "2022-01-20T12:39:21Z")

</div>

Is there a way to align a column to Left AND align the header of this column to Right

This code align all the 4th column but I need a different alignement for the header of the 4th column

`me.ColumnAlignmentAt(3) = Listbox.Alignments.Right`

---

<div class="post-metadata">

**Author:** ![Sascha\_S](https://forum.xojo.com/user_avatar/forum.xojo.com/sascha_s/32/22328_2.png) [@Sascha\_S](https://forum.xojo.com/u/Sascha_S)\
**Post date:** [January 20, 2022, 2:24pm UTC](https://forum.xojo.com/t/listbox-header-align/68087/2 "2022-01-20T14:24:37Z")

</div>

No, there isn’t. And AFAIK, not even [piDog’s DataViewer](https://www.pidog.com/piDogScrollingCanvas/piDogScrollingCanvasDocs/piDogDataView_Folder/piDogDataView/DataView/index.html) or [GraffitiListbox](https://graffitisuite.com/wiki/doku.php?id=desktop:listbox) offering it.

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [January 20, 2022, 2:39pm UTC](https://forum.xojo.com/t/listbox-header-align/68087/3 "2022-01-20T14:39:06Z")

</div>

Remove Xojo Header and set your own…

Or… draw the text in the Header Text Paint Event…

---

<div class="post-metadata">

**Author:** ![Anthony\_G\_Cyphers](https://forum.xojo.com/user_avatar/forum.xojo.com/anthony_g_cyphers/32/16862_2.png) [@Anthony\_G\_Cyphers](https://forum.xojo.com/u/Anthony_G_Cyphers)\
**Post date:** [January 20, 2022, 3:04pm UTC](https://forum.xojo.com/t/listbox-header-align/68087/4 "2022-01-20T15:04:45Z")

</div>

This has actually already been added for the next release by request of another user. If a user with an active Desktop Edition subscription wants the update, they just need to open a [ticket](https://support.graffitisuite.com/) and request it and I’ll take care of it when I get in late tonight.

---

<div class="post-metadata">

**Author:** ![jim\_mckay](https://forum.xojo.com/user_avatar/forum.xojo.com/jim_mckay/32/905_2.png) [@jim\_mckay](https://forum.xojo.com/u/jim_mckay)\
**Post date:** [January 20, 2022, 3:53pm UTC](https://forum.xojo.com/t/listbox-header-align/68087/5 "2022-01-20T15:53:50Z")

</div>

Dataview also has this functionality. You can set it in the ListColumn object…

```auto
dim lc as piDogDataView.ListColumn = me.Column(0)
lc.HeadingAlignment = piDogDataView.DataView.AlignmentRight
me.Column(0) = lc

```

There’s quite a few [other options in ListColumn](https://www.pidog.com/piDogScrollingCanvas/piDogScrollingCanvasDocs/piDogDataView_Folder/piDogDataView/ListColumn/index.html) as well.

---

<div class="post-metadata">

**Author:** ![Sebastien\_REMY](https://forum.xojo.com/user_avatar/forum.xojo.com/sebastien_remy/32/1946_2.png) [@Sebastien\_REMY](https://forum.xojo.com/u/Sebastien_REMY)\
**Post date:** [January 20, 2022, 5:05pm UTC](https://forum.xojo.com/t/listbox-header-align/68087/7 "2022-01-20T17:05:45Z")

</div>

Documentation on PaintHeaderContent is very short, anyone can post a code snippet ?

[https://documentation.xojo.com/api/user\_interface/desktop/desktoplistbox.html.PaintHeaderContent](https://documentation.xojo.com/api/user_interface/desktop/desktoplistbox.html.PaintHeaderContent)

---

<div class="post-metadata">

**Author:** ![Ramon\_SASTRE](https://forum.xojo.com/user_avatar/forum.xojo.com/ramon_sastre/32/326_2.png) [@Ramon\_SASTRE](https://forum.xojo.com/u/Ramon_SASTRE)\
**Post date:** [January 20, 2022, 5:55pm UTC](https://forum.xojo.com/t/listbox-header-align/68087/8 "2022-01-20T17:55:50Z")

</div>

Is this what you want?

![imatge](https://forum.xojo.com/uploads/default/original/2X/f/f5c104f0755beb47788cf2bd92034533c5a9268a.png)

That is the code I used:

Function PaintHeaderBackground(g As Graphics, column As Integer) As Boolean  
g.DrawingColor = Color.White  
g.FillRectangle 0, 0, g.width, g.height  
return true  
End Function

Function PaintHeaderContent(g As Graphics, column As Integer) As Boolean  
Var t As String = "hello world "  
Var x As Double = g.TextWidth(t)  
g.DrawingColor = color.black  
g.DrawText t, g.width-x, g.FontAscent  
Return True  
End Function

---

<div class="post-metadata">

**Author:** ![Pawel\_Soltysinski](https://forum.xojo.com/user_avatar/forum.xojo.com/pawel_soltysinski/32/23522_2.png) [@Pawel\_Soltysinski](https://forum.xojo.com/u/Pawel_Soltysinski)\
**Post date:** [January 24, 2022, 7:32am UTC](https://forum.xojo.com/t/listbox-header-align/68087/9 "2022-01-24T07:32:58Z")

</div>

what is the problem? the only problem is to take care about cell alignment when adding value/row:

```auto
Listbox1.HeaderAt(0)="column name"
Listbox1.ColumnAlignmentAt(0)=DesktopListBox.Alignments.Right

Listbox1.AddRow "test value"
Listbox1.CellAlignmentAt(0,0)=DesktopListBox.Alignments.Center

```

---

<div class="post-metadata">

**Author:** ![Sebastien\_REMY](https://forum.xojo.com/user_avatar/forum.xojo.com/sebastien_remy/32/1946_2.png) [@Sebastien\_REMY](https://forum.xojo.com/u/Sebastien_REMY)\
**Post date:** [January 24, 2022, 8:29am UTC](https://forum.xojo.com/t/listbox-header-align/68087/10 "2022-01-24T08:29:02Z")

</div>

> [@Pawel\_Soltysinski](#):
>
> ```auto
> Listbox1.HeaderAt(0)="column name"
> Listbox1.ColumnAlignmentAt(0)=DesktopListBox.Alignments.Right
> 
> Listbox1.AddRow "test value"
> Listbox1.CellAlignmentAt(0,0)=DesktopListBox.Alignments.Center
> 
> ```

Thank you, it’s work fine 👋 . The real question is why you can not change the header alignement after adding rows ? 🙄

---

<div class="post-metadata">

**Author:** ![Pawel\_Soltysinski](https://forum.xojo.com/user_avatar/forum.xojo.com/pawel_soltysinski/32/23522_2.png) [@Pawel\_Soltysinski](https://forum.xojo.com/u/Pawel_Soltysinski)\
**Post date:** [January 24, 2022, 9:39am UTC](https://forum.xojo.com/t/listbox-header-align/68087/11 "2022-01-24T09:39:39Z")

</div>

…because there is no property to change the alignment of header only. If you set column alignment after adding rows - it will reset alignment for whole column.
