How do you CENTER & BOLD the labels of the columns (i.e headings) using ListView. I did not understand the below found in MSDN..

/*
If a column is added to a list-view control with index 0 (the leftmost column) and with
LVCFMT_RIGHT or LVCFMT_CENTER specified, the text is not right-aligned or centered. The text in the index 0 column is left-aligned. Therefore if you keep inserting columns with index 0, the text in all columns are left-aligned. If you want the first column to be
right-aligned or centered you can make a dummy column, then insert one or more columns with index 1 or higher and specify the alignment you require. Finally delete the dummy column.
*/

Also I want the last column to occupy the remaining width of the window even if resizing of the Main Window takes place.

This reply is a bit late. But I hope maybe somebody else will learn something from it.

The list view control has a default font and this is the same for the column and the items. So to change this I think that you should change the font of the list view to the required font with the attributes set as you want, and then enter the columns. After entering the column you can deselect the font and the default font is back in action. I have not tried it. But as it works for other controls like buttons and such it should work here too.

The meaning of the MSDN quote is that you cant change the allignment of the column with index 0 using LVCFMT_RIGHT or LVCFMT_CENTER. To change its allignment you make the list view control think that its index is not zero. To do this what you first insert a first dummy column. Then you insert your actual first column with index 1. You can change the allignment of the column with index 1. After doing that, you delete your dummy column with index 0. Then the column that you wanted as the first column ( but which you inserted after the dummy column ) will become the first one automatically. Hope you get the idea.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.