ImageList プロパティを使用するためのコントロールについては、フォームに ImageList コンポーネントを配置する必要があります。次に、デザインタイムで、フォームの現在のすべての ImageList コントロールの名前を含むドロップダウン ボックスから関連するコントロールのプロパティ ページで ImageList プロパティを設定できます。ランタイムで ImageList をコントロールと関連付けるために、この例で示すように、コントロールの ImageList プロパティを使用したい ImageList コンポーネントに設定します。
UltraWinGrid1.ImageList = ImageList1 を設定します。
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
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]; }