delphilistviewright-justified

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?


Solution

  • 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.