Hide

SftTree/OCX 7.5 - ActiveX Tree Control

Display
Print

MakeOptimal Method, SftTreeSplitter Object

Positions the splitter bar optimally.

Syntax

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

object

A SftTreeSplitter object.

Comments

The MakeOptimal method positions the splitter bar optimally, so the left pane can display as much data as possible without a horizontal scroll bar.

MakeOptimal is only available for a split tree control (see Splitter.Visible).

Before using MakeOptimal, the best horizontal extent for the panes must be set using the Items.HorizontalExtent property or the Items.RecalcHorizontalExtent method. Once set, MakeOptimal can then be used to position the splitter bar optimally, so the left pane can display as much data as possible without a horizontal scroll bar.

MakeOptimal uses the current width of the tree control window to determine the allowable position of the splitter bar. If the tree control window is too small, the splitter bar may not be optimally set. This is particularly noticeable if the tree control window is resized after MakeOptimal is used.

The coordinates of the splitter bar can be retrieved using the Splitter.GetPosition method.

The Splitter.Width property is used to change the width of the splitter bar.

Examples

VB.NET

        AddMessage(2, "anyone@acompany.com", "Re: You're fired", "10/11/05", 82, False)
        AddMessage(1, "me@mycompany.com", "You're hired", "10/01/05", 4, False)
        AddMessage(1, "anyone@acompany.com", "Re: You're hired", "10/11/05", 6, False)
        ItemIndex = AxSftTree1.Items.ItemIndex(m_SavedFolder)
        AxSftTree1.get_Item(ItemIndex).Collapse(False)
        m_DeletedFolder = AddFolder("Deleted", "Deleted messages", 0)
        AxSftTree1.ColumnsObj.MakeOptimal()
        AxSftTree1.Items.RecalcHorizontalExtent()
        AxSftTree1.Splitter.MakeOptimal()
        ' allow sorting
        AxSftTree1.Headers.SortIndicators = SftTreeHeaderSortIndicatorsConstants.headerSortIndicatorsSftTreeAuto

        AxSftTree1.Items.Current = 0
        AxSftTree1_CaretChange(Me, New _DSftTreeEvents_CaretChangeEvent(0))
    End Sub

VB6

            AddMessage 1, "me@mycompany.com", "You're fired", "10/08/05", 2, False
            AddMessage 2, "anyone@acompany.com", "Re: You're fired", "10/11/05", 82, False
            AddMessage 1, "me@mycompany.com", "You're hired", "10/01/05", 4, False
            AddMessage 1, "anyone@acompany.com", "Re: You're hired", "10/11/05", 6, False
            .Item(.Items.ItemIndex(SavedFolder)).Collapse False
        DeletedFolder = AddFolder("Deleted", "Deleted messages", 0)
        .ColumnsObj.MakeOptimal
        .Items.RecalcHorizontalExtent
        .Splitter.MakeOptimal
        ' allow sorting
        .Headers.SortIndicators = headerSortIndicatorsSftTreeAuto

        .Items.Current = 0
        SftTree1_CaretChange 0  ' to update column headers
    End With
End Sub

C#

                AddMessage(2, "anyone@acompany.com", "Re: You're fired", "10/11/05", 82, false);
                AddMessage(1, "me@mycompany.com", "You're hired", "10/01/05", 4, false);
                AddMessage(1, "anyone@acompany.com", "Re: You're hired", "10/11/05", 6, false);
                ItemIndex = axSftTree1.Items.get_ItemIndex(m_SavedFolder);
                axSftTree1.get_Item(ItemIndex).Collapse(false);
            m_DeletedFolder = AddFolder("Deleted", "Deleted messages", 0);
            axSftTree1.ColumnsObj.MakeOptimal();
            axSftTree1.Items.RecalcHorizontalExtent();
            axSftTree1.Splitter.MakeOptimal();
            // allow sorting
            axSftTree1.Headers.SortIndicators = SftTreeHeaderSortIndicatorsConstants.headerSortIndicatorsSftTreeAuto;

            axSftTree1.Items.Current = 0;
            axSftTree1_CaretChange(this, new _DSftTreeEvents_CaretChangeEvent(0));
        }

C++

        AddMessage(1, _T("me@mycompany.com"), _T("You're fired"), _T("10/08/05"), 2, FALSE);
        AddMessage(2, _T("anyone@acompany.com"), _T("Re: You're fired"), _T("10/11/05"), 82, FALSE);
        AddMessage(1, _T("me@mycompany.com"), _T("You're hired"), _T("10/01/05"), 4, FALSE);
        AddMessage(1, _T("anyone@acompany.com"), _T("Re: You're hired"), _T("10/11/05"), 6, FALSE);
        m_vTree->Item[m_vTree->Items->ItemIndex[m_SavedFolder]]->Collapse(VARIANT_FALSE);
    m_DeletedFolder = AddFolder(_T("Deleted"), _T("Deleted messages"), 0);
    m_vTree->ColumnsObj->MakeOptimal();
    m_vTree->Items->RecalcHorizontalExtent();
    m_vTree->Splitter->MakeOptimal();
    // allow sorting
    m_vTree->Headers->SortIndicators = headerSortIndicatorsSftTreeAuto;

    m_vTree->Items->Current = 0;
    OnCaretChangeSftTree1(0); // to update column headers

    return TRUE;  // return TRUE  unless you set the focus to a control

See Also SftTreeSplitter Object | Object Hierarchy


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