How to: Enable Automatic Height Adjustment
- 2 minutes to read
- Automatic Node Height Adjustment
- Disable Automatic Node Height Adjustment
- Specify Custom Height
- Automatic Node Height and Image Data
- Automatic Node Height and Text Data
- Specify Custom Image Height
Automatic Node Height Adjustment
The Tree list node height is set to match content height.
Disable Automatic Adjustment
To disable automatic height adjustment, set the TreeList.OptionsBehavior.AutoNodeHeight
(see TreeListOptionsBehavior.AutoNodeHeight) property to False.
In this mode, node height corresponds to the height of a single text line. Images are scaled to fit automatically calculated height.
Specify Custom Node Height
To specify custom node height, disable automatic height adjustment, and specify the height using the TreeList.RowHeight property.
Once the custom node height has been set, text fields are properly centered, and images are scaled.
To customize node height, you can also handle the TreeList.CalcNodeHeight event, and specify the CalcNodeHeightEventArgs.NodeHeight event argument.
Automatic Node Height and Image Data
When automatic height adjustment is turned on, images are displayed using their original dimensions as specified in the database. If you delete an image, node height will be automatically adjusted.
Automatic Node Height and Text Data
To enable automatic height adjustment for cells with text data, select the column and use the TreeListColumn.ColumnEdit property to assign a new MemoEdit editor.
Ensure that the RepositoryItemMemoEdit.WordWrap property is set to true and then run the application. The Tree List adjusts the node height, so that the text is completely visible. If you add or remove the text, the height will be updated.
Specify Custom Image Height
To specify custom height for images, assign a PictureEdit to the column. Use the editor’s RepositoryItemPictureEdit.CustomHeight property to specify the required value.
If you run the application, you will see that images are now truncated. The editor allows you to see the entire image by dragging it.
To shrink the images so that they fit the specified cell height, set RepositoryItemPictureEdit.SizeMode to PictureSizeMode.Zoom. Note that in this mode, the node keeps its height if you remove the image.