views:

208

answers:

1

In past, I am using Listview and using below code can show a particular image for particular memId. But now I need to replace listview with Infragistics.Win.UltraWinGrid problem arise how i show image for ultragrid.

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

Please suggest.

A: 

I think you will want to set an image for a specific column of your grid. I would do this in InitializeRow event of the grid. Here is a sample:

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

BPerreault