StrataFrame Forum

Substituting Values or Controls in Listview

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

By Keith Chisarik - 9/7/2006

I have a listview populated at the with CopyDataFrom. There is one field that is a bit, I would like to show either a checkbox with the correct checked status, a 'Y' or 'N' character, or an image (red X, green check) instead of the 0 or 1 value in the table.



Can this be done and can you point me in the right direction?
By Keith Chisarik - 9/7/2006

Opps I forgot, I would also like to sort listview columns when I click the column header. This is all stuff I used to do standard in a VFP grid, I would like to be able to use SF controls whenever possible though.
By StrataFrame Team - 9/8/2006

You can only show an image for the field if it is the first column in the list view (the icon column); in which case, you have to set the ImageKey or ImageIndex within the RowPopulating event of the listview.  As for displaying an alternate value, you will need to set the column to PopulatedThroughEvent within the PopulationDataSourceSettings.  Once that is set, you can manually specify the display value for the column through the RowPopulating event.

To sort a list, you will need to add a handler to the ColumnClick event of the list view and set the ListViewItemSorter property of the list view to a new instance of the MicroFour.StrataFrame.UI.Windows.Forms.ListViewColumnSorter class and specify the column and the direction to sort by.  You might also have to explicitly call Sort() on the listview, but I don't think so... it should automatically sort when you set the sorter.