StrataFrame Forum

Listview:Right align the 1st column

http://forum.strataframe.net/Topic20978.aspx

By Michel Levy - 12/3/2008

Hi,

I need to right align the 1st column of a listview, where data are Integer.
I understand that these integer are "mapped" to text for displaying in the listview, but why is it impossible to set alignment to right on the first column (and only the first, alignment works fine on other columns)
either in property sheet or in ListPopulating event, it does not work.

As a workaround, I set the format to D5, but the readability is poor. What do I forget? How could I right align, or PADL with spaces?

thanks

By Edhy Rijo - 12/3/2008

Hi Michael,

Maybe you can have a dummy fist column (Index 0) with 0 width and not header, then have the real column (Index 1) which will hold your integer and can get the alignment to the right with no problem.

I believe there should be some technical explanation as to why the first column can not be aligned to the right.

By Trent L. Taylor - 12/3/2008

I believe there should be some technical explanation as to why the first column can not be aligned to the right.

Yes, but it wil have to come from Microsoft! Smile  Our ListView inherits from the standard .NET ListView. This will change in future releases so that we have 100% control over things just like this.  Dustin will post a workaround shortly.

By Dustin Taylor - 12/3/2008

Edhy hit on the workaround already. Just add a 0 width column and make sure it is the topmost column in your columns collection. See the attachments for an illustration on how to configure the columns and proof that it works Smile.

As Trent said, this is behavior that has been inherited from the standard Microsoft ListView. The first column added to the column's collection cannot be set to right aligned via the property sheet, and the topmost column in the collection (whether it was the first column created or not) will always be left aligned regardless of what the alignment property is set to. I have no idea why they do it that way, but until we have our own listview that doesn't inherit from Microsoft's, we are going to have to work around it w00t.

By Michel Levy - 12/3/2008

Eddy,

Of course, you are right, I'll add a dummy column w00t

Thanks a lot...

Trent,

I could not believe it was simply a "bug by design" from MS Doze