Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is it possible to format (center aligned) a single column of a ListBox?

I want to format a single column of a ListBox as Centered.

Is that possible?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Perhaps you can work around it. If you make a listbox containing 3 columns each with the same column width and you fill column 1 and 3 with nothing or one space and you fill column 2 with data, than it is centered in a way:

Private Sub UserForm_Initialize()

    With Me.lstBox
        .ColumnCount = 3
        .ColumnWidths = 10
        .BoundColumn = 2
        .AddItem
        .List(0, 1) = "Example"
    End With

End Sub

Above code results in:

enter image description here

I don’t think dat VBA has a property to center allign data in a listbox (I read that VB6 does have it by the way). But this is not a single column I’ll give you that 😉

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading