Hide

SftTree/OCX 7.5 - ActiveX Tree Control

Display
Print

CaretChange Event, SftTree Object

The caret location changes.

Syntax

VB.NETPrivate Sub object_CaretChange(ByVal sender As Object, ByVal e As EventArgumentType) Handles object.CaretChange
VBPrivate Sub object_CaretChange(ByVal ItemIndex As Long)
C#.NETvoid object_CaretChange(object sender, EventArgumentType e);
VC++void OnCaretChangeobject(long ItemIndex);
CHRESULT OnCaretChangeobject(long ItemIndex);

object

A SftTree object.

ItemIndex

The new zero-based index of the current item.

Comments

The CaretChange event occurs when the caret location changes.

The current item is the item that has the caret rectangle, which is a rectangle outlining the border of the current item (see Items.Current). When using the up and down arrow keys, the user changes the current item (or caret location, also see Items.NoSelection). The current item is not necessarily the same as the selected item. The Item.Selected property can be used to change the selected item.

ItemIndex may be 0, even if the tree control is empty.

The current item can also be affected by the Items.DropHighlightStyle property.

Examples

VB.NET

        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

    Private Sub AxSftTree1_CaretChange(ByVal sender As Object, ByVal e As AxSftTreeLib75._DSftTreeEvents_CaretChangeEvent) Handles AxSftTree1.CaretChange
        ' set column headers based on selected item
        Dim ID As Integer
        ID = AxSftTree1.get_Item(e.itemIndex).ID
        If ID = m_InboxFolder Or ID = m_OutboxFolder Or ID = m_SavedFolder Or ID = m_DeletedFolder Then

VB6

        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

Private Sub SftTree1_CaretChange(ByVal ItemIndex As Long)
    With SftTree1
        ' set column headers based on selected item
        Select Case .Item(ItemIndex).ID

C#

            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));
        }

        private int AddFolder(string Folder, string Desc, int Count)
        {
            int ItemIndex = axSftTree1.Items.Add(Folder); // add folder
            axSftTree1.get_Cell(ItemIndex, 1).Text = Desc; // add description
            axSftTree1.get_Cell(ItemIndex, 3).Text = Count.ToString(); // add number of messages

C++

    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
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

See Also SftTree Object | Object Hierarchy


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