Hide

SftTree/OCX 7.5 - ActiveX Tree Control

Display
Print

MakeOptimal Method, SftTreeColumn Object

Sets the column's optimal width so that the text and graphics of all items can be displayed without being clipped horizontally.

Syntax

VB.NETobject.MakeOptimal()
VBobject.MakeOptimal
C#.NETvoid object.MakeOptimal();
VC++HRESULT object->MakeOptimal();
CHRESULT object->raw_MakeOptimal();

object

A SftTreeColumn object.

Comments

The MakeOptimal method sets the column's optimal width so that the text and graphics of all items can be displayed without being clipped horizontally.

This method resizes the column 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.

The ColumnsObj.MakeOptimal method can be used to set the optimal column width of all columns.

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. MakeOptimal 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.

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

Examples

VB.NET

Private Sub AxSftTree1_ItemCollapsed(ByVal sender As System.Object, ByVal e As AxSftTreeLib75._DSftTreeEvents_ItemCollapsedEvent) Handles AxSftTree1.ItemCollapsed
    If e.itemIndex = 2 Then
        AxWindowsMediaPlayer1.Ctlcontrols.pause()
    End If
End Sub

Private Sub AxSftTree1_ItemDblClick(ByVal sender As System.Object, ByVal e As AxSftTreeLib75._DSftTreeEvents_ItemDblClickEvent) Handles AxSftTree1.ItemDblClick
    If e.areaType = SftTreeAreaTypeConstants.constSftTreeColumnRes Then
        AxSftTree1.get_Column(e.colIndex).MakeOptimal()
    End If
End Sub
End Class

VB6

    If ItemIndex = 2 Then
        ' Here we make sure that the media starts playing when the control is visible
        WindowsMediaPlayer1.Controls.Play
    End If
End Sub

Private Sub SftTree1_ItemDblClick(ByVal ItemIndex As Long, ByVal ColIndex As Integer, ByVal AreaType As Integer, ByVal Button As Integer, ByVal Shift As Integer)
    If AreaType = constSftTreeColumnRes Then
        SftTree1.Column(ColIndex).MakeOptimal
    End If
End Sub

Private Sub WebBrowserPictureBox_Resize()
    ' resize the web browser control (which is inside the picture box)
    ' every time the picture box is resized.
    WebBrowser1.Height = WebBrowserPictureBox.Height

C#

        private void axSftTree1_ItemCollapsed(object sender, _DSftTreeEvents_ItemCollapsedEvent e) {
            if (e.itemIndex == 2)
                axWindowsMediaPlayer1.Ctlcontrols.pause();
        }

        private void axSftTree1_ItemDblClick(object sender, _DSftTreeEvents_ItemDblClickEvent e) {
            if (e.areaType == (short) SftTreeAreaTypeConstants.constSftTreeColumnRes) {
                axSftTree1.get_Column(e.colIndex).MakeOptimal();
            }
        }
    }
}

C++

    // here we make sure that the media stops playing when the control is not visible
    if (ItemIndex == 2)
        m_WMPDialog.m_pCtlWMP1->controls->pause();
}

void CContentWindowsDlg::OnItemDblClickSfttree1(long ItemIndex, short ColIndex, short AreaType, short Button, short Shift)
{
    if (AreaType == constSftTreeColumnRes)
        m_vTree->Column[ColIndex]->MakeOptimal();
}

BEGIN_EVENTSINK_MAP(CContentWindowsDlg, CDialog)
    //{{AFX_EVENTSINK_MAP(CContentWindowsDlg)
	ON_EVENT(CContentWindowsDlg, IDC_SFTTREE1, 42 /* ItemExpanded */, OnItemExpandedSfttree1, VTS_I4)
	ON_EVENT(CContentWindowsDlg, IDC_SFTTREE1, 41 /* ItemCollapsed */, OnItemCollapsedSfttree1, VTS_I4)
	ON_EVENT(CContentWindowsDlg, IDC_SFTTREE1, 5 /* ItemDblClick */, OnItemDblClickSfttree1, VTS_I4 VTS_I2 VTS_I2 VTS_I2 VTS_I2)

See Also SftTreeColumn Object | Object Hierarchy


Last Updated 08/13/2020 - (email)
© 2024 Softel vdm, Inc.