property Items.CellImages ([Item as Variant], [ColIndex as Variant]) as Variant
Specifies an additional list of icons shown in the cell.

 TypeDescription 
   Item as Variant A long expression that indicates the item's handle.  
   ColIndex as Variant A long expression that indicates the column's index, a string expression that indicates the column's caption or the column's key.   
   Variant A string expression that indicates the list of icons shown in the cell.  
The CellImages property assigns multiple icons to a cell. The CellImage property assign a single icon to the cell. Instead if multiple icons need to be assigned to a single cell you have to use the CellImages property. The CellImages property takes a list of additional icons and display them in the cell. The list is separated by ','  and should contain numbers that represent indexes to Images list collection. Use the ItemFromPoint property to retrieve the part of the control being clicked. Use the CellHasCheckBox property to add a check box to a cell. Use the CellHasRadioButton property to assign a radio button to a cell. Use the CellPicture property to load a custom size picture to a cell. Use the <img> HTML tag to insert icons inside the cell's caption, if the CellCaptionFormat property is exHTML.

The following VB sample assigns the first and third icon to the cell:

With Tree1.Items
        .CellImages(.ItemByIndex(0), 1) = "1,3"
End With

The following VB sample displays the index of icon being clicked:

Private Sub Tree1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim i As HITEM, h As HitTestInfoEnum, c As Long
    With Tree1
        i = .ItemFromPoint(X / Screen.TwipsPerPixelX, Y / Screen.TwipsPerPixelY, c, h)
    End With
    If (i <> 0) Then
        If exHTCellIcon = (h And exHTCellIcon) Then
            Debug.Print "The index of icon being clicked is: " & (h And &HFFFF0000) / 65536
        End If
    End If
End Sub

The following VB sample changes the icon being clicked when the cell contains multiple icons, using the CellImages property, or a single icon using the CellImage property. We assume that the control contains at least two icons.  

Private Sub Tree1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim i As HITEM, h As HitTestInfoEnum, c As Long
    With Tree1
        i = .ItemFromPoint(X / Screen.TwipsPerPixelX, Y / Screen.TwipsPerPixelY, c, h)
    End With
    If (i <> 0) Then
        If exHTCellIcon = (h And exHTCellIcon) Then
            Dim iImage As Long, j As Long
            iImage = (h And &HFFFF0000) / 65536
            With Tree1.Items
                If (Len(.CellImages(i, c)) > 0) Then
                    Dim cI() As String, nCI As String
                    cI = Split(.CellImages(i, c), ",")
                    cI(iImage) = cI(iImage) Mod 2 + 1
                    For j = LBound(cI) To UBound(cI)
                        nCI = nCI + cI(j) + IIf(j < UBound(cI), ",", "")
                    Next
                    .CellImages(i, c) = nCI
                Else
                    .CellImage(i, c) = .CellImage(i, c) Mod 2 + 1
                End If
            End With
        End If
    End If
End Sub

The following C++ sample assigns the first and the third icon to the cell:

#include "Items.h"
CItems items = m_tree.GetItems();
items.SetCellImages( COleVariant( items.GetFocusItem() ), COleVariant( (long)0 ), COleVariant( "1,3" ) );

The following C++ sample displays the index of icon being clicked:

#include "Items.h"
void OnMouseUpTree1(short Button, short Shift, long X, long Y) 
{
	CItems items = m_tree.GetItems();
	long c = 0, hit = 0, h = m_tree.GetItemFromPoint( X, Y, &c, &hit);
	if ( h != 0 )
	{
		if ( ( hit & 0x44 /*exHTCellIcon*/ ) == 0x44 )
		{
			CString strFormat;
			strFormat.Format( "The index of icon being clicked is: %i\n", (hit >> 16) );
			OutputDebugString( strFormat );
		}
	}
}

The following VB.NET sample assigns the first and the third icon to the cell:

With AxTree1.Items
    .CellImages(.FocusItem, 0) = "1,3"
End With

The following VB.NET sample displays the index of icon being clicked:

Private Sub AxTree1_MouseUpEvent(ByVal sender As Object, ByVal e As AxEXTREELib._ITreeEvents_MouseUpEvent) Handles AxTree1.MouseUpEvent
    With AxTree1
        Dim i As Integer, c As Integer, hit As EXTREELib.HitTestInfoEnum
        i = .get_ItemFromPoint(e.x, e.y, c, hit)
        If (Not (i = 0)) Then
            Debug.WriteLine("The index of icon being clicked is: " & (hit And &HFFFF0000) / 65536)
        End If
    End With
End Sub

The following C# sample assigns the first and the third icon to the cell:

axTree1.Items.set_CellImages(axTree1.Items.FocusItem, 0, "1,3");

The following C# sample displays the index of icon being clicked:

private void axTree1_MouseUpEvent(object sender, AxEXTREELib._ITreeEvents_MouseUpEvent e)
{
	int c = 0;
	EXTREELib.HitTestInfoEnum hit;
	int i = axTree1.get_ItemFromPoint(e.x, e.y, out c, out hit);
	if ((i != 0))
	{
		if ((Convert.ToUInt32(hit) & Convert.ToUInt32(EXTREELib.HitTestInfoEnum.exHTCellIcon)) == Convert.ToUInt32(EXTREELib.HitTestInfoEnum.exHTCellIcon))
		{
			string s = axTree1.Items.get_CellCaption(i, c).ToString();
			s = "Cell: " + s + ", Icon's Index: " + (Convert.ToUInt32(hit) >> 16).ToString();
			System.Diagnostics.Debug.WriteLine(s);
		}
	}
}

The following VFP sample assigns the first and the third icon to the cell:

with thisform.Tree1.Items
	.DefaultItem = .FocusItem
	.CellImages(0,0) = "1,3"
endwith

The following VFP sample displays the index of icon being clicked:

*** ActiveX Control Event ***
LPARAMETERS button, shift, x, y

local c, hit
c = 0
hit = 0
with thisform.Tree1
	.Items.DefaultItem = .ItemFromPoint( x, y, @c, @hit )
	if ( .Items.DefaultItem <> 0 )
		if ( bitand( hit, 68 )= 68 )
			wait window nowait .Items.CellCaption( 0, c ) + " " + Str( Int((hit - 68)/65536) )
		endif
	endif
endwith

Add the code to the MouseUp, MouseMove or MouseDown event,

 


Send comments on this topic.
1999-2017 Exontrol.COM, Software. All rights reserved.