Hide

SftTree/OCX 7.5 - ActiveX Tree Control

Display
Print

ItemIndex Property, SftTreeItems Object

Returns the item index given an item ID.

Syntax

Get

VB.NETItemIndex = object.ItemIndex(ByVal ID As Integer) As Integer
VBItemIndex = object.ItemIndex(ByVal ID As Long) As Long
C#.NETint ItemIndex = object.get_ItemIndex(int ID);
VC++long ItemIndex = object->ItemIndex[long ID];
long ItemIndex = object->GetItemIndex(long ID);
CHRESULT object->get_ItemIndex(long ID, long* ItemIndex);

object

A SftTreeItems object.

ID

The item ID of the item whose index is to be returned.

ItemIndex

Returns the item index given an item ID. -1 is returned if no item has a matching ID.

Comments

The ItemIndex property returns the item index given an item ID.

The item ID returned by the Item.ID property does not change throughout the lifetime of an item. Even if an item changes its index position because other items are deleted or inserted, the item ID remains constant. The item index describes the zero-based position of an item in a tree control.

Examples

VB.NET

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim ItemIndex As Integer
        m_InboxFolder = AddFolder("Inbox", "Viewed and unviewed mail", 10)
        AddMessage(1, "support@softelvdm.com", "Re: A support question", "10/09/05", 88, True)
        AddMessage(1, "anyone@acompany.com", "Re: Why did you say that", "10/10/05", 5, False)
        AddMessage(1, "anyone@acompany.com", "Re: You're fired", "10/11/05", 82, True)
        AddMessage(1, "anyone@acompany.com", "Re: You're hired", "10/11/05", 6, False)
        ItemIndex = AxSftTree1.Items.ItemIndex(m_InboxFolder)
        AxSftTree1.get_Item(ItemIndex).Collapse(False)
        m_OutboxFolder = AddFolder("Outbox", "Mail about to be sent", 2)
        AddMessage(1, "me@mycompany.com", "Re: You're fired", "10/11/05", 5, False)
        AddMessage(1, "anyone@acompany.com", "Re: Why did you say that", "10/10/05", 5, False)
        ItemIndex = AxSftTree1.Items.ItemIndex(m_OutboxFolder)
        AxSftTree1.get_Item(ItemIndex).Collapse(False)
        m_SavedFolder = AddFolder("Saved", "Saved messages", 2)
        AddMessage(1, "me@mycompany.com", "A support question", "10/09/05", 3, False)

VB6

Private Sub Form_Load()
    With SftTree1
        InboxFolder = AddFolder("Inbox", "Viewed and unviewed mail", 10)
            AddMessage 1, "support@softelvdm.com", "Re: A support question", "10/09/05", 88, True
            AddMessage 1, "anyone@acompany.com", "Re: Why did you say that", "10/10/05", 5, False
            AddMessage 1, "anyone@acompany.com", "Re: You're fired", "10/11/05", 82, True
            AddMessage 1, "anyone@acompany.com", "Re: You're hired", "10/11/05", 6, False
            .Item(.Items.ItemIndex(InboxFolder)).Collapse False
        OutboxFolder = AddFolder("Outbox", "Mail about to be sent", 2)
            AddMessage 1, "me@mycompany.com", "Re: You're fired", "10/11/05", 5, False
            AddMessage 1, "anyone@acompany.com", "Re: Why did you say that", "10/10/05", 5, False
            .Item(.Items.ItemIndex(OutboxFolder)).Collapse False
        SavedFolder = AddFolder("Saved", "Saved messages", 2)
            AddMessage 1, "me@mycompany.com", "A support question", "10/09/05", 3, False
            AddMessage 2, "support@softelvdm.com", "Re: A support question", "10/09/05", 88, True
            AddMessage 3, "me@mycompany.com", "Re: A support question", "10/09/05", 3, False

C#

        private void Form1_Load(object sender, System.EventArgs e) {
            int ItemIndex;
            m_InboxFolder = AddFolder("Inbox", "Viewed and unviewed mail", 10);
                AddMessage(1, "support@softelvdm.com", "Re: A support question", "10/09/05", 88, true);
                AddMessage(1, "anyone@acompany.com", "Re: Why did you say that", "10/10/05", 5, false);
                AddMessage(1, "anyone@acompany.com", "Re: You're fired", "10/11/05", 82, true);
                AddMessage(1, "anyone@acompany.com", "Re: You're hired", "10/11/05", 6, false);
                ItemIndex = axSftTree1.Items.get_ItemIndex(m_InboxFolder);
                axSftTree1.get_Item(ItemIndex).Collapse(false);
            m_OutboxFolder = AddFolder("Outbox", "Mail about to be sent", 2);
                AddMessage(1, "me@mycompany.com", "Re: You're fired", "10/11/05", 5, false);
                AddMessage(1, "anyone@acompany.com", "Re: Why did you say that", "10/10/05", 5, false);
                ItemIndex = axSftTree1.Items.get_ItemIndex(m_OutboxFolder);
                axSftTree1.get_Item(ItemIndex).Collapse(false);
            m_SavedFolder = AddFolder("Saved", "Saved messages", 2);
                AddMessage(1, "me@mycompany.com", "A support question", "10/09/05", 3, false);

C++

    m_pBoldCellFont->put_Bold(TRUE);


    m_InboxFolder = AddFolder(_T("Inbox"), _T("Viewed and unviewed mail"), 10);
        AddMessage(1, _T("support@softelvdm.com"), _T("Re: A support question"), _T("10/09/05"), 88, TRUE);
        AddMessage(1, _T("anyone@acompany.com"), _T("Re: Why did you say that"), _T("10/10/05"), 5, FALSE);
        AddMessage(1, _T("anyone@acompany.com"), _T("Re: You're fired"), _T("10/11/05"), 82, TRUE);
        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_InboxFolder]]->Collapse(VARIANT_FALSE);
    m_OutboxFolder = AddFolder(_T("Outbox"), _T("Mail about to be sent"), 2);
        AddMessage(1, _T("me@mycompany.com"), _T("Re: You're fired"), _T("10/11/05"), 5, FALSE);
        AddMessage(1, _T("anyone@acompany.com"), _T("Re: Why did you say that"), _T("10/10/05"), 5, FALSE);
        m_vTree->Item[m_vTree->Items->ItemIndex[m_OutboxFolder]]->Collapse(VARIANT_FALSE);
    m_SavedFolder = AddFolder(_T("Saved"), _T("Saved messages"), 2);
        AddMessage(1, _T("me@mycompany.com"), _T("A support question"), _T("10/09/05"), 3, FALSE);
        AddMessage(2, _T("support@softelvdm.com"), _T("Re: A support question"), _T("10/09/05"), 88, TRUE);

See Also SftTreeItems Object | Object Hierarchy


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