Sets the optimal column width so that the text and graphics of all items can be displayed.
|VB.NET||object.MakeColumnOptimal(ByVal ColIndex As Short)|
|VB||object.MakeColumnOptimal(ByVal ColIndex As Integer)|
|C#.NET||void object.MakeColumnOptimal(short ColIndex);|
|VC++||HRESULT object->MakeColumnOptimal(short ColIndex);|
|C||HRESULT object->raw_MakeColumnOptimal(short ColIndex);|
The zero-based column number to resize. If -1 is specified, all columns are resized.
The MakeColumnOptimal method sets the optimal column width so that the text and graphics of all items can be displayed.
This method resizes a specified column or all columns to the optimal width so that the column header and each cell can be completely displayed without being truncated or clipped. The Column.OptimalWidth method can be used to calculate a column's optimal width without resizing the column. The column width can be changed using the Column.Width property.
By changing tree control properties, the optimal column width may change. Adding items, setting new cell graphics and changing cell text are a few of the actions that can affect the optimal column width. The column width may have to be set again to allow items to be completely visible.
The tree control does not automatically adjust column widths.
Cells which merge into an adjacent column are not considered when calculating the optimal column width.
The last (or only) column may be an "open-ended" column. If the ColumnsObj.OpenEnded property is set to True, the last displayed column will always use the space remaining between the previous column and the right edge of the tree control window.
Calculating the optimal column width can be a time consuming operation, particularly if many items have been added to the tree control. The Items.CalcLimit property can be used to limit the maximum number of items to consider for optimal column width calculation. MakeColumnOptimal scans all items to determine the best column width, but can be limited to a specific number of items using the Items.CalcLimit property. This reduces the time spent to calculate the optimal width, but may still leave some items clipped.