2010-03-23 8 views
2

Dans le passé, j'utilise Listview et en utilisant le code ci-dessous peut montrer une image particulière pour un memId particulier. Mais maintenant j'ai besoin de remplacer listview avec Infragistics.Win.UltraWinGrid problème se pose comment je montre l'image pour ultragrid.Comment ajouter un imagelist dans Infragistics.Win.UltraWinGrid?

For Each LItem As ListViewItem In Me.dvParticipants.Items 
      If CInt(LItem.SubItems(2).Text) = memid Then 
       LItem.ImageIndex = imageindex 
      End If 
     Next 

Veuillez nous suggérer.

Répondre

2

Je pense que vous voudrez définir une image pour une colonne spécifique de votre grille. Je le ferais dans l'événement InitializeRow de la grille. Voici un exemple:

Private Sub ugGrid_InitializeRow(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeRowEventArgs) Handles ugGrid.InitializeRow 

    'pull the image from a resource' 
    Dim exclamationIcon As Bitmap = My.Resources.Exclamation_Icon_15x15 
    exclamationIcon.Tag = EXCLAMATION_ICON_TAG 

    'get the data source of the row, I only want this image to appear under certain' 
    'conditions ' 

    Dim actualHist As ActualHistory = DirectCast(e.Row.ListObject, HistoryRow).ActualHistory 
    If Not IsNothing(actualHist) AndAlso actualHist.IsEligible(actualProdHist) Then 
     'here the condition is met, set the image on the correct column, the one' 
     ' with key of "Descriptor"' 
     e.Row.Cells("Descriptor").Appearance.Image = exclamationIcon 
     e.Row.Cells("Descriptor").Appearance.ImageHAlign = HAlign.Right 
    Else 
     e.Row.Cells("Descriptor").Appearance.Image = Nothing 
    End If 
End Sub