How do you set the Delphi ListView.Columns[0] to be right justified?

1.6k views Asked by At

I have a Delphi ListView with ViewStyle := vsReport. I'm displaying numeric data and would like to set all the columns to right justiied. I have been able to right justify all the columns except columns[0]. For some reason, columns[0] won't allow the taRightJustify. It only allows taLeftJustify.

Is it possible to set columns[0] to be right justified? If so how do you do this?

2

There are 2 answers

0
Remy Lebeau On BEST ANSWER

TListView does not natively support what you are asking for, due to a Microsoft limitation rather than a VCL limitation:

http://msdn.microsoft.com/en-us/library/windows/desktop/bb774743.aspx

The alignment of the leftmost column is always LVCFMT_LEFT; it cannot be changed.

The only way to align the text of columns[0] is to owner-draw it.

Otherwise, switch to another control, such as Virtual Treeview.

0
BennyBechDk On

A workaround can be to start adding a column and set the first column with 0 with (to make it invisible). Just remember that all columns are now in subItems.