Hide

SftTree/OCX 7.5 - ActiveX Tree Control

Display
Print

VirtualItem Event, SftTree Object

The virtual data source is called to provide item information.

Syntax

VB.NETPrivate Sub object_VirtualItem(ByVal sender As Object, ByVal e As EventArgumentType) Handles object.VirtualItem
VBPrivate Sub object_VirtualItem(ByVal RowIndex As Long, ItemObject As VirtualItem)
C#.NETvoid object_VirtualItem(object sender, EventArgumentType e);
VC++void OnVirtualItemobject(long RowIndex, IVirtItem* ItemObject);
CHRESULT OnVirtualItemobject(long RowIndex, IVirtItem* ItemObject);

object

A SftTree object.

RowIndex

The zero-based index number of the item for which item information is requested.

ItemObject

A VirtualItem object which should be updated by the application to reflect the item attributes.

Comments

The VirtualItem event occurs when the virtual data source is called to provide item information.

The VirtualItem event occurs when the tree control is in virtual mode (see VirtualMode). The event must be implemented by the application to provide information and item attributes to SftTree/OCX.

SftTree/OCX caches the items that are currently displayed in the tree control's client area. If an item is changed by the application's virtual data source (i.e. its external data source), the VirtualItemChanged method should be called to notify SftTree/OCX.

To enable graphics components, the VirtualPictures method must be used. The VirtualCount method is used to define the number of items represented by the tree control.

The VirtualItem object is used by the application to set all properties for the requested item RowIndex. The application provides all data for the requested item RowIndex using the VirtualItem.Item property.

While handling the VirtualItem event, the application cannot modify or retrieve any tree control attributes.

Examples

VB.NET

    Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        AxSftTree1.RowColumnHeader.Image.NETImageObject = imageListWorld.Images(m_PicCount)
        m_PicCount = m_PicCount + 1
        If m_PicCount >= imageListWorld.Images.Count Then
            m_PicCount = 0
        End If
    End Sub

    Private Sub AxSftTree1_VirtualItem(ByVal sender As Object, ByVal e As AxSftTreeLib75._DSftTreeEvents_VirtualItemEvent) Handles AxSftTree1.VirtualItem
        e.itemObject.Item.Cell(0).Text = "Item " & e.rowIndex
        e.itemObject.Item.Cell(1).Text = "Cell " & e.rowIndex
        e.itemObject.Item.Cell(2).Text = "A"
        e.itemObject.Item.Cell(3).Text = (e.rowIndex Mod 7)
        e.itemObject.Item.Cell(4).Text = "Last " & e.rowIndex
        e.itemObject.Item.RowHeader.Text = "R" & e.rowIndex
        e.itemObject.Item.Enabled = ((e.rowIndex Mod 2) = 0)

VB6

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 SftTree1_VirtualItem(ByVal RowIndex As Long, ByVal ItemObject As VirtualItem)
    ItemObject.Item.Cell(0).Text = "Item " & RowIndex
    ItemObject.Item.Cell(1).Text = "Cell " & RowIndex
    ItemObject.Item.Cell(2).Text = "A"
    ItemObject.Item.Cell(3).Text = RowIndex Mod 7
    ItemObject.Item.Cell(4).Text = "Last " & RowIndex
    ItemObject.Item.RowHeader.Text = "R" & RowIndex
    ItemObject.Item.Enabled = ((RowIndex Mod 2) = 0)

C#

        private void Timer1_Tick(object sender, System.EventArgs e) {
            axSftTree1.RowColumnHeader.Image.NETImageObject = imageListWorld.Images[m_PicCount];
            ++m_PicCount;
            if (m_PicCount >= imageListWorld.Images.Count)
                m_PicCount = 0;
        }

        private void axSftTree1_VirtualItem(object sender, AxSftTreeLib75._DSftTreeEvents_VirtualItemEvent e) {

            e.itemObject.Item.get_Cell(0).Text = "Item " + e.rowIndex;
            e.itemObject.Item.get_Cell(1).Text = "Cell " + e.rowIndex.ToString();
            e.itemObject.Item.get_Cell(2).Text = "A";
            e.itemObject.Item.get_Cell(3).Text = (e.rowIndex % 7).ToString();
            e.itemObject.Item.get_Cell(4).Text = "Last " + e.rowIndex.ToString();
            e.itemObject.Item.RowHeader.Text = "R" + e.rowIndex.ToString();
            e.itemObject.Item.Enabled = ((e.rowIndex % 2) == 0);

C++

}

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

void CVirtualDlg::OnVirtualItemSftTree1(long RowIndex, LPDISPATCH ItemObject)
{
    IVirtualItemPtr pItemObj = ItemObject;
    CString str;
    str.Format(_T("Item %ld"), RowIndex);
    pItemObj->Item->Cell[0]->Text = (LPCTSTR) str;

    str.Format(_T("Cell %ld"), RowIndex);

See Also SftTree Object | Object Hierarchy


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