ListView.HasUnevenRows Property

Definition

Gets or sets a Boolean value that indicates whether this ListView element has uneven rows.

public bool HasUnevenRows { get; set; }
member this.HasUnevenRows : bool with get, set

Property Value

true if this ListView control has uneven rows. Otherwise, false

Remarks

To automatically size row height to fit content, the developer first sets the HasUnevenRows property to true; and, second, either leaves RowHeight at its default value of -1, or sets it to -1 if it has been changed.

Alternatively, to ensure a constant size for all rows, the developer first sets HasUnevenRows to false, and then either: leaves RowHeight at its default value of -1 (or sets it back to that value if it has been changed) in order to get the default height for the system; or sets the RowHeight property to the desired uniform row height.

A more detailed discussion follows, below.

When the app developer sets the HasUnevenRows property to false, the behavior of the list view depends on the RowHeight property. First, if the developer sets the RowHeight property to a positive value, then all rows in the ListView, irrespective of the height of their content, will be as tall as the specified RowHeight property value. Second, if the develper instead does not set the RowHeight property, or sets it to a nonpositive value, then all rows in the ListView, irrespective of the height of their content, will have the default row height for the system.

When the app developer sets the HasUnevenRows property to true, the behavior of the list view still depends on the RowHeight property. First, if the developer either does not set the RowHeight property or sets it to -1, list view items are autosized to fit their contents. This is the desired behavior and the intended use case for a HasUnevenRows value of true, as noted above. Second, if the developer sets the RowHeight property to 0 or to a negative value other than -1, then all rows in the ListView will, irrespective of the height of their content, have the default height for the system. Third, and finally, if the developer sets RowHeight to a positive value, then all rows in the ListView will, irrespective of the height of their content, be as tall as RowHeight, as if HasUnevenRows had been set to false.

Applies to