Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 446
Michael Riley - AKA Gunny Avatar asked Aug 19 '14 03:08

Michael Riley - AKA Gunny


1 Answers

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.

like image 166
Remy Lebeau Avatar answered Oct 25 '22 19:10

Remy Lebeau