Formatting Items
Depending on the ViewType, RadListView provides a convenient way for customizing the items.
Formatting items in ListView and IconsView modes
Items appearance in RadListView can be customized by making use of the VisualItemFormatting event. The following example, demonstrates how you can change the color of an item which is being selected.
By using this event to customize the items appearance, you should always provide an else clause, where you reset the appearance settings which you have introduced. This is necessary since RadListView uses data virtualization, which might lead to unpredicted appearance results when items are being reused.
Figure 1: Customizing items in the VisualItemFormatting event
Customizing items when using the VisualItemFormatting event
Formatting cells in DetailsView mode
The DetailsView of RadListView provides a grid-like interface for displaying items with more than one data field. It is possible to customize each cell element, using the CellFormatting event.
Cell elements are created only for currently visible cells and they are being reused, when scrolling. In order to prevent applying the formatting to other cell elements, all applied styles should be reset for the rest of the cell elements.
Let’s assume that the RadListView is bound to the Products table from the Northwind database. The code snippet below demonstrates how to apply different colors and font for the data cells in the control, considering the “Discontinued” cell’s value:
Figure 2: Customizing cells when using the CellFormatting event
Customizing cells when using the CellFormatting event
In order to customize the header cells, the e.CellElement property should be cast to the DetailListViewHeaderCellElement type.