Infragistics(R) NetAdvantage(R) Windows Forms
ImageList Property
See Also  Example E-mail your feedback on this topic.
Infragistics.Win.UltraWinGrid Namespace > UltraGridBase Class : ImageList Property

Returns or sets the ImageList component, if any, that is associated with the control.

Syntax

Visual Basic (Declaration) 
Public Property ImageList As ImageList
C# 
public ImageList ImageList {get; set;}

Example

Following code shows how ImageList property works.

Visual BasicCopy Code
Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid

  Private Sub Button89_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button89.Click

      ' Set the ImageList property to an isntance of ImageList. Typically the way
      ' you create an ImageList is to add an ImageList component on the form and add
      ' images to it through the designer.
      Me.UltraGrid1.ImageList = New System.Windows.Forms.ImageList()

      Dim image As Image = Nothing

      Try
          ' Open an image.
          image = Image.FromFile("d:\\test.bmp")
      Catch exc As Exception
          MessageBox.Show(Me, exc.Message, "Error opening file.", MessageBoxButtons.OK, MessageBoxIcon.Error)
          Return
      End Try

      ' Add the image to the image list.
      Dim imageIndex As Integer = Me.UltraGrid1.ImageList.Images.Add(image, Color.Transparent)

      ' Set the Image properties of various appearances to the index of the image
      ' in the ultra grid.
      Me.UltraGrid1.DisplayLayout.Override.RowSelectorAppearance.Image = imageIndex
      Me.UltraGrid1.DisplayLayout.Override.HeaderAppearance.Image = imageIndex

      ' You can also set the Image properties to the image itself.
      Me.UltraGrid1.DisplayLayout.Override.CellAppearance.Image = Me.UltraGrid1.ImageList.Images(0)

  End Sub
C#Copy Code
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;

private void button89_Click(object sender, System.EventArgs e)
{

	// Set the ImageList property to an isntance of ImageList. Typically the way
	// you create an ImageList is to add an ImageList component on the form and add
	// images to it through the designer.
	this.ultraGrid1.ImageList = new System.Windows.Forms.ImageList( );

	Image image = null;

	try
	{
		// Open an image.
		image = Image.FromFile( "d:\\test.bmp" );
	}
	catch ( Exception exc )
	{
		MessageBox.Show( this, exc.Message, "Error opening file.", MessageBoxButtons.OK, MessageBoxIcon.Error );
		return;
	}

	// Add the image to the image list.
	int imageIndex = this.ultraGrid1.ImageList.Images.Add( image, Color.Transparent );

	// Set the Image properties of various appearances to the index of the image
	// in the ultra grid.
	this.ultraGrid1.DisplayLayout.Override.RowSelectorAppearance.Image = imageIndex;
	this.ultraGrid1.DisplayLayout.Override.HeaderAppearance.Image = imageIndex;

	// You can also set the Image properties to the image itself.
	this.ultraGrid1.DisplayLayout.Override.CellAppearance.Image = this.ultraGrid1.ImageList.Images[0];

}

Remarks

For the control to use the ImageList property, you must put an ImageList component on the form. Then, at design time, you can set the ImageList property in the associated control's property page from the drop down box containing the names of all the ImageList controls currently on the form. To associate an ImageList with a control at run time, set the control's ImageList property to the ImageList component you want to use, as in this example:

Set UltraWinGrid1.ImageList = ImageList1

See Also