Hide

SftTree/OCX 7.5 - ActiveX Tree Control

Display
Print

Level Property, SftTreeItem Object

Defines the item's level number.

Syntax

Get

VB.NETLvl = object.Level As Short
VBLvl = object.Level As Integer
C#.NETshort Lvl = object.Level;
VC++short Lvl = object->Level;
short Lvl = object->GetLevel();
CHRESULT object->get_Level(short* Lvl);

Put

VB.NETobject.Level = Lvl As Short
VBobject.Level = Lvl As Integer
C#.NETshort object.Level = Lvl;
VC++short object->Level = Lvl;
void object->PutLevel(short Lvl);
CHRESULT object->put_Level(short Lvl);

object

A SftTreeItem object.

Lvl

Defines the item's level number. The valid range is 0 through 63.

Comments

The Level property defines the item's level number.

The Level property determines the "indentation" of an item. By changing an item's level number, its parent relation is automatically adjusted by the tree control. Using this method, the application does not have to manipulate any parent/child relationships, but can instead treat the entire list of items in a tree control as a linear list, an array of items.

The root (or highest) level is level 0, dependents are on levels 1, 2, 3 and lower. The valid range of levels is 0 through 63.

When changing an item's level using the Level property, its (current and new) parent items will automatically be expanded to make the item visible.

The indentation of item levels can be defined using the Items.Indentation property.

While logically the first item in the tree control should be at level 0, this is not necessary. Also, a parent item does not necessarily require an immediate dependent (on the next lower level); its first dependent could be on a much lower level. While this is very application specific, SftTree/OCX does allow you to build hierarchies of items where parent/child relationships don't have to follow strict rules.

Examples

VB.NET

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        AxSftTree1.BulkUpdate = True

        ' Add all screen fonts to the tree control
        Dim ScreenIndex As Integer
        ScreenIndex = AxSftTree1.Items.Add("Fonts")
        AxSftTree1.get_Item(ScreenIndex).Level = 0

        ' display fonts
        Dim Counter As Integer = 0
        Dim ff As FontFamily
        For Each ff In System.Drawing.FontFamily.Families
            ' add font name
            Dim newFont As Font

VB6

    Dim C As SftTreeCell

    With SftTree1
        ' Mass-Update
        .BulkUpdate = True

        ' Add all screen fonts to the tree control
        ScreenIndex = .Items.Add("Screen Fonts")
        .Item(ScreenIndex).Level = 0
        ' display screen fonts
        MaxFonts = Screen.FontCount
        ' limit to 20 fonts
        If MaxFonts > 20 Then MaxFonts = 20
        For I = 0 To MaxFonts - 1
            ' add the item
            ItemIndex = .Items.Add(Screen.Fonts(I))

C#

            }
        }

        private void Form1_Load(object sender, System.EventArgs e) {
            axSftTree1.BulkUpdate = true;

            // Add all screen fonts to the tree control
            int ScreenIndex = axSftTree1.Items.Add("Fonts");
            axSftTree1.get_Item(ScreenIndex).Level = 0;
            // display fonts

            int counter = 0;
            foreach (FontFamily ff in System.Drawing.FontFamily.Families) {
                // add font name
                Font newFont = null;
                try {

C++

    fd.lpstrName = FontName;
    fd.cySize.int64 = 10 * 10000L; // 10pt font
    fd.sWeight = FW_NORMAL;
    IFontDispPtr pFontDisp;
    HRESULT hr = OleCreateFontIndirect(&fd, IID_IFontDisp, (void**)&pFontDisp);
    if (FAILED(hr)) return;

    long ItemIndex = m_vTree->Items->Add(FontName);
     m_vTree->Item[ItemIndex]->Level = 1;
     m_vTree->Cell[ItemIndex][1]->Text = FontName;
     m_vTree->Cell[ItemIndex][0]->PutRefFont(pFontDisp);

}

/*static*/ int CALLBACK CListFontDlg::FontEnumeratorProc(ENUMLOGFONTEX *lpelfe, NEWTEXTMETRICEX *lpntme, DWORD FontType, LPARAM lParam)
{

See Also SftTreeItem Object | Object Hierarchy


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


Spring Break!

Our offices will be closed this week (March 18 through March 22).

We'll be back March 24 to address any pending sales and support issues.