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 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. The CellPictureWidth property specifies the width in pixels of the cell's picture. If it is not specified, the picture's size determines the width to paint the picture inside the cell. The CellPictureHeight property specifies the height in pixels of the cell's picture. If it is not specified, the picture's size determines the height to paint the picture inside the cell. Use the <img> built-in HTML tag to insert multiple custom size picture to the same cell. Use the Def( exCellDrawPartsOrder) property to specify the order of the drawing parts inside the cell.

The following VB samples loads picture from a file:

Grid1.Items.CellPicture(h, 0) = LoadPicture("c:\winnt\logo.gif")

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

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

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

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

axGrid1.Items.set_CellPicture(axGrid1.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.Grid1.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.