property Items.CellPicture ([Item as Variant], [ColIndex as Variant]) as Variant
Retrieves or sets the cell's picture.

 TypeDescription 
   Item as Variant A long expression that indicates the item's handle.  
   ColIndex as Variant A long expression that indicates the cell's handle or the column's index, a string expression that indicates the column's caption or the column's key.  
   Variant A Picture object being displayed on the cell ( 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 with a cell a check or radio button, an icon, a  picture and a caption. Use the CellPicture property  to associate a picture with a cell. You can use the CellPicture property when you want to display images with different widths in 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 specify the height of the item. The CellPictureWidth and CellPictureHeight properties specifies the size of the area where the cell's picture is stretched.

The following VB sample shows how to load a picture to a cell:

ComboBox1.Items.CellPicture(ComboBox1.Items.ItemByIndex(0), 0) = LoadPicture("c:/winnt/logo.gif")

or

ComboBox1.Items.CellPicture(ComboBox1.Items.ItemByIndex(0), 0) = "c:\winnt\logo.gif"

The following VB sample loads a picture to a cell using a BASE64 encodes strings:

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

 

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

With AxComboBox1.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:

axComboBox1.Items.set_CellPicture(axComboBox1.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.ComboBox1.Items
	.DefaultItem = .FocusItem
	.CellPicture( 0, 0 ) = LoadPicture("c:\winnt\zapotec.bmp")
endwith


 


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