如何在Infragistics.Win.UltraWinGrid中添加图像列表?

时间:2010-03-23 13:00:33

标签: .net infragistics

过去,我使用的是Listview,使用下面的代码可以显示特定memId的特定图像。但现在我需要用Infragistics.Win.UltraWinGrid替换listview 问题出现了我如何展示ultragrid的图像。

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

请建议。

1 个答案:

答案 0 :(得分:2)

我认为您需要为网格的特定列设置图像。我会在网格的InitializeRow事件中执行此操作。这是一个示例:

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