Hide

SftTree/NET 2.0 - Tree Control for Windows Forms

Display
Print

MakeOptimal Method, RowHeadersClass Class

Sets the row header area's optimal width so that the cell contents in the row header area can be displayed without being clipped horizontally.

Class: RowHeadersClass
Namespace: Softelvdm.SftTreeNET
Assembly: Softelvdm.SftTreeNET

Syntax

public void MakeOptimal(
    int MaxScan,
    bool VisibleOnly );
Public Sub MakeOptimal(
    ByVal MaxScan As Integer,
    ByVal VisibleOnly As Boolean )

Parameters

MaxScan

Defines the maximum number of items to scan to determine the optimal row header area width or 0 to scan all items.

VisibleOnly

Defines whether only visible items should be considered to determine the optimal row header area width. Visible items are items whose parent items are expanded.

Comments

Sets the row header area's optimal width so that the cell contents in the row header area can be displayed without being clipped horizontally.

This method resizes the row header area to its optimal width so that each cell in the row header area can be completely displayed without being truncated or clipped. The RowHeadersClass.GetOptimalWidth method can be used to calculate the row header area's optimal width without resizing the row header area. The row header area width can be changed using the RowHeadersClass.Width property.

By changing tree control properties, the optimal row header area width may change. Adding items, setting new cell contents are a few of the actions that can affect the optimal row header area width. The row header area width may have to be set again to allow cells to be completely visible.

The tree control does not automatically adjust the row header area width.

Calculating the optimal row header area width can be a time consuming operation, particularly if many items have been added to the tree control. The MaxScan parameter can be used to limit the maximum number of items to consider for optimal row header area width calculation. MakeOptimal scans all items to determine the best row header area width, but can be limited to a specific number of items using the MaxScan parameter. This reduces the time spent to calculate the optimal width, but may still leave some items clipped.

If items are not visible because their parent items are collapsed, these can be excluded from the optimal width calculation by setting the VisibleOnly parameter to True.

Individual row headers can be excluded from the optimal width calculation by setting their RowHeaderClass.WidthIgnore property.

Examples

C#

            item.RowHeader.Text = "Vertical";
            Font f = new Font("Arial", 8, FontStyle.Bold, GraphicsUnit.Point);
            item.RowHeader.TextPart.Font = f;
            item.RowHeader.TextPart.Format |= StringFormatFlags.DirectionVertical;
            item.RowHeader.Parts.Add(new ImagePartClass(img));

            // Make column widths and row header area width optimal
            sftTree1.Columns.MakeOptimal(0, false);
            sftTree1.RowHeaders.MakeOptimal(0, false);
            // Activate the horizontal scrollbar
            sftTree1.RecalcHorizontalExtent();
            sftTree1.Initializing = false;
        }

        // ItemClick event
        private void sftTree1_ItemClick(object sender, ItemClickEventArgs e) {

VB.NET

    item.RowHeader.Text = "Vertical"
    Dim f As Font = New Font("Arial", 8, FontStyle.Bold, GraphicsUnit.Point)
    item.RowHeader.TextPart.Font = f
    item.RowHeader.TextPart.Format = item.RowHeader.TextPart.Format Or StringFormatFlags.DirectionVertical
    item.RowHeader.Parts.Add(New ImagePartClass(img))

    ' Make column widths and row header area width optimal
    sftTree1.Columns.MakeOptimal(0, False)
    sftTree1.RowHeaders.MakeOptimal(0, False)
    ' Activate the horizontal scrollbar
    sftTree1.RecalcHorizontalExtent()
    sftTree1.Initializing = False
End Sub

' ItemClick event
Private Sub sftTree1_ItemClick(ByVal sender As Object, ByVal e As Softelvdm.SftTreeNET.ItemClickEventArgs) Handles sftTree1.ItemClick

See Also RowHeadersClass Class | Classes | SftTree/NET 2.0



Spring Break!

Our offices will be closed this week (March 18 through March 22).

We'll be back March 24 to address any pending sales and support issues.