property Items.CellPicture (Index as Long, ColIndex as Variant) as Variant
Retrieves or sets a value that indicates the Picture object displayed by the cell.

TypeDescription
Index as Long A long expression that indicates the index of the item.
ColIndex as Variant A long expression that indicates the column's index, or a string expression that indicates the column's caption or column's key.
Variant A Picture object that indicates the cell's picture. ( A Picture object implements IPicture interface ), a string expression that indicates the base64 encoded string that holds a picture object. Use the eximages tool to save your picture as base64 encoded format.

The control can associate to a cell a check or radio button, an icon, multiple icons, a  picture and a caption. Use the CellPicture property  to associate a picture to a cell. You can use the CellPicture property when you want to display images with different widths into a cell. Use the CellImage property to associate an icon from Images collection. Use the CellImages property to assign multiple icons to a cell. 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 ItemHeight property to enlarge the item's height. The CellPictureWidth and CellPictureHeight properties specifies the size of the area where the cell's picture is stretched.

The following VB sample loads a picture from a file:

With List1.Items
    .CellPicture(.FirstVisibleItem, 0) = "c:\winnt\logo.gif"
End With

The following sample loads the picture whose base64 representation is:

"gBHJJGHA5MIqAAXAD3AENhozhpmhqZhrMhr/h0QGcQM0QTMQZkQf8QAESGcSM0STMSZkSf8SAEUGcUM0UTMUZkUf8UAEWGcWM0WTMWZkWf8WAEYGcYM0YTMYZkYf8Yh8ak0yn1KAEbrkdmcbkNLjcljcdlMzjstpcdmMbj81mcfnNLj89sEnkNDn8ho8ijcjpszkdRpcjiMclE0oFMrdes9woMnwEls0plMroMpl8qjuYlc3oMrncstMpltDoMto8ujubl9PoMvqcwusrmM2oVOrcftFxmd5kc0t+ez+n1+3uM1m83nNPm89uUr5s5otPnNJj+jnfOqNPncVkEsnFEqFbsNqudFn+DkshzOh1OxoMxvOn6fUndEkNF1NDoqiqOoy+NUnMAqOqakMMl7sKSoypK2ka1ropa+JGpjANc0TVNkmLgte7aju8p6esGl7uqjAEDqTCzZJ3BCpxgh0ZRnGkaxtG8cRzHUdx5HqHBCfICAChprgAFkZIQhQAAQjBXgSDgkFgUBgkGBAJg0fhTlgUJhkGGQHBgDh8CeERggqB4Zg8BBqDKMRiiyf4YC8fZ7ieIxgkSDIEgMIBSGMJZkj+RBrEgVIcAkUgkkCFgyFAJg8naIAHBkNYVA4SAUhmQBiAAR4JA6YAUBGY5RgGG4pg8DBdAMZAIhADhrDILoZhWQANBANYHBwHAADoJpREkA5GA0KAsBiY5NBkI1LBiORCAGA4RiADx+hQKZKkYJ5fCAU4dDgahVGXMwJE6QQCj2UBhE0UAHGscgUEmIZXGqVQ1kcIg/CYcwIlEToBGiZwlHoPAYkEAYwBWHAUHGABAkGZA5HSDwQnGQBhiqTIpgiKweEAdBonGGQDi4E45DAIJGkGZI+A6dBsAUAggnMEY1mMFRaAkEAAGgXh/k8cw4CgQIGEEDgdGoQhlhKAZ7GiexViMYRBBsXBhBiCAQGAEpPjsBhqgCDJrAqJx1lQKAAnYdhYBYWBymKMY3myU5jDSaAOlAIYsjGNpzkAAIc5iK4MkeZAwEACpdB6KRLCqH4gAOYgzFecpIA0LIyHIOAgAgIhkkIJAABEDJiE2N4xgaCpCDwMgACqcQBgcUgbmGEZHigUwDAyCoMCqKIAF0OpgkEIgoAKeBH9qchihGJgCCkLAojeKQjEqKAkAMWlDiyWY+DMKgLl8SJAgGSIjBCGRlgYdZ4iIKQiDWRpCEQJYDgYWhKESHgQkIEhDFCm8aAUg0jWDyA0Twch9ApHQKAQgFgtBQCAAAHZAQ="

The following VB sample associates a picture to a cell by loading it from a base64 encoded string:

Dim s As String
s = "gBHJJGHA5MIqAAXAD3AENhozhpmhqZhrMhr/h0QGcQM0QTMQZkQf8QAESGcSM0STMSZkSf8SAEUGcUM0UTMUZkUf8UAEWGcWM0WTMWZkWf8WAEYGcYM0YTMYZkYf8Yh8ak0yn1KAEbrkdmcbkNLjcljcdlMzjstpcdmMbj81mcfnNLj89sEnkNDn8ho8ijcjpszkdRpcjiMclE0oFMrdes9woMnwEls0plMroMpl8qjuYlc3oMrncstMpltDoMto8ujubl9PoMvqcwusrmM2oVOrcftFxmd5kc0t+ez+n1+3uM1m83nNPm89uUr5s5otPnNJj+jnfOqNPncVkEsnFEqFbsNqudFn+DkshzOh1OxoMxvOn6fUndEkNF1NDoqiqOoy+NUnMAqOqakMMl7sKSoypK2ka1ropa+JGpjANc0TVNkmLgte7aju8p6esGl7uqjAEDqTCzZJ3BCpxgh0ZRnGkaxtG8cRzHUdx5HqHBCfICAChprgAFkZIQhQAAQjBXgSDgkFgUBgkGBAJg0fhTlgUJhkGGQHBgDh8CeERggqB4Zg8BBqDKMRiiyf4YC8fZ7ieIxgkSDIEgMIBSGMJZkj+RBrEgVIcAkUgkkCFgyFAJg8naIAHBkNYVA4SAUhmQBiAAR4JA6YAUBGY5RgGG4pg8DBdAMZAIhADhrDILoZhWQANBANYHBwHAADoJpREkA5GA0KAsBiY5NBkI1LBiORCAGA4RiADx+hQKZKkYJ5fCAU4dDgahVGXMw"
s = s + "JE6QQCj2UBhE0UAHGscgUEmIZXGqVQ1kcIg/CYcwIlEToBGiZwlHoPAYkEAYwBWHAUHGABAkGZA5HSDwQnGQBhiqTIpgiKweEAdBonGGQDi4E45DAIJGkGZI+A6dBsAUAggnMEY1mMFRaAkEAAGgXh/k8cw4CgQIGEEDgdGoQhlhKAZ7GiexViMYRBBsXBhBiCAQGAEpPjsBhqgCDJrAqJx1lQKAAnYdhYBYWBymKMY3myU5jDSaAOlAIYsjGNpzkAAIc5iK4MkeZAwEACpdB6KRLCqH4gAOYgzFecpIA0LIyHIOAgAgIhkkIJAABEDJiE2N4xgaCpCDwMgACqcQBgcUgbmGEZHigUwDAyCoMCqKIAF0OpgkEIgoAKeBH9qchihGJgCCkLAojeKQjEqKAkAMWlDiyWY+DMKgLl8SJAgGSIjBCGRlgYdZ4iIKQiDWRpCEQJYDgYWhKESHgQkIEhDFCm8aAUg0jWDyA0Twch9ApHQKAQgFgtBQCAAAHZAQ="
With List1.Items
    .CellPicture(.FocusItem, 0) = s
End With

The following C++ loads a picture from a file:

#include 
BOOL LoadPicture( LPCTSTR szFileName, IPictureDisp** ppPictureDisp )
{
	BOOL bResult = FALSE;
	if ( szFileName )
	{
		OFSTRUCT of;
		HANDLE hFile = NULL;;
#ifdef _UNICODE
		USES_CONVERSION;
		if ( (hFile = (HANDLE)OpenFile( W2A(szFileName), &of, OF_READ | OF_SHARE_COMPAT)) != (HANDLE)HFILE_ERROR )
#else
		if ( (hFile = (HANDLE)OpenFile( szFileName, &of, OF_READ | OF_SHARE_COMPAT)) != (HANDLE)HFILE_ERROR )
#endif
		{
			*ppPictureDisp = NULL;
			DWORD dwHighWord = NULL, dwSizeLow = GetFileSize( hFile, &dwHighWord );
			DWORD dwFileSize = dwSizeLow;
			HRESULT hResult = NULL;
			if ( HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, dwFileSize) )
				if ( void* pvData = GlobalLock( hGlobal ) )
				{
					DWORD dwReadBytes = NULL;
					BOOL bRead = ReadFile( hFile, pvData, dwFileSize, &dwReadBytes, NULL );
					GlobalUnlock( hGlobal );
					if ( bRead )
					{
						CComPtr spStream;
						_ASSERTE( dwFileSize == dwReadBytes );
						if ( SUCCEEDED( CreateStreamOnHGlobal( hGlobal, TRUE, &spStream) ) )
							if ( SUCCEEDED( hResult = OleLoadPicture( spStream, 0, FALSE, IID_IPictureDisp, (void**)ppPictureDisp ) ) )
								bResult = TRUE;
					}
				}
			CloseHandle( hFile );
		}
	}
	return bResult;
}

IPictureDisp* pPicture = NULL;
if ( LoadPicture( "c:\\winnt\\zapotec.bmp", &pPicture ) )
{
	COleVariant vtPicture;
	V_VT( &vtPicture ) = VT_DISPATCH;
	pPicture->QueryInterface( IID_IDispatch, (LPVOID*)&V_DISPATCH( &vtPicture ) );
	CItems items = m_list.GetItems();
	items.SetCellPicture( items.GetFocusItem() , COleVariant(long(0)), vtPicture );
	pPicture->Release();
}

The following VB.NET sample loads a picture from a file:

With AxList1.Items
    .CellPicture(.FocusItem, 0) = IPDH.GetIPictureDisp(Image.FromFile("c:\winnt\zapotec.bmp"))
End With 

where the IPDH class is defined like follows:

Public Class IPDH
    Inherits System.Windows.Forms.AxHost

    Sub New()
        MyBase.New("")
    End Sub

    Public Shared Function GetIPictureDisp(ByVal image As Image) As Object
        GetIPictureDisp = AxHost.GetIPictureDispFromPicture(image)
    End Function

End Class

The following C# sample loads a picture from a file:

axList1.Items.set_CellPicture(axList1.Items.FocusItem, 0, IPDH.GetIPictureDisp(Image.FromFile("c:\\winnt\\zapotec.bmp")));

where the IPDH class is defined like follows:

internal class IPDH : System.Windows.Forms.AxHost
{
	public IPDH() : base("")
	{
	}

	public static object GetIPictureDisp(System.Drawing.Image image)
	{
		return System.Windows.Forms.AxHost.GetIPictureDispFromPicture( image );
	}
}

The following VFP sample loads a picture from a file:

with thisform.List1.Items
	.CellPicture( .FocusItem, 0 ) = LoadPicture("c:\winnt\zapotec.bmp")
endwith