如何使用ObjectListView显示图像列表中的所有图像?

发布于 2024-12-23 05:55:38 字数 115 浏览 1 评论 0原文

如何使用 ObjectListView 显示图像列表中的所有图像?在 ObjectListView 的主页中,他们展示了如何在 C# 中执行此操作(我对 C# 和委托不太擅长)。但我无法让它在 VB.net 中工作。

How do I use a ObjectListView to show all the images in a image-list ? In the home-site of ObjectListView they have shown how to do this in C# (I am not that good with c# and delegates). But I can't get it to work in VB.net.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

纸伞微斜 2024-12-30 05:55:38

以下是他们示例的直接翻译:

Me.mainColumn.ImageGetter = Function(row As Object) Do
    Dim key As String = Me.GetImageKey(row)
    If Not Me.listView.LargeImageList.Images.ContainsKey(key) Then
        Dim smallImage As Image = Me.GetSmallImageFromStorage(key)
        Dim largeImage As Image = Me.GetLargeImageFromStorage(key)
        Me.listView.SmallImageList.Images.Add(key, smallImage)
        Me.listView.LargeImageList.Images.Add(key, largeImage)
    End If
    Return key
End Function

这只适用于最新版本的 VB.NET,因为它使用内联函数。对于旧版本,您可以这样更改它:

创建一个类似于以下内容的函数:

Public Function GetImageFromList(row As Object) As String
        Dim key As String = Me.GetImageKey(row)
        If Not Me.listView.LargeImageList.Images.ContainsKey(key) Then
            Dim smallImage As Image = Me.GetSmallImageFromStorage(key)
            Dim largeImage As Image = Me.GetLargeImageFromStorage(key)
            Me.listView.SmallImageList.Images.Add(key, smallImage)
            Me.listView.LargeImageList.Images.Add(key, largeImage)
        End If
        Return key
End Function

然后将列的图像获取器设置为:

Me.mainColumn.ImageGetter = AddressOf GetImageFromList

Here is a direct translation of their example:

Me.mainColumn.ImageGetter = Function(row As Object) Do
    Dim key As String = Me.GetImageKey(row)
    If Not Me.listView.LargeImageList.Images.ContainsKey(key) Then
        Dim smallImage As Image = Me.GetSmallImageFromStorage(key)
        Dim largeImage As Image = Me.GetLargeImageFromStorage(key)
        Me.listView.SmallImageList.Images.Add(key, smallImage)
        Me.listView.LargeImageList.Images.Add(key, largeImage)
    End If
    Return key
End Function

That will only work with the most recent version of VB.NET because it uses an inline function. You can alter it like this for older versions:

Create a function similar to:

Public Function GetImageFromList(row As Object) As String
        Dim key As String = Me.GetImageKey(row)
        If Not Me.listView.LargeImageList.Images.ContainsKey(key) Then
            Dim smallImage As Image = Me.GetSmallImageFromStorage(key)
            Dim largeImage As Image = Me.GetLargeImageFromStorage(key)
            Me.listView.SmallImageList.Images.Add(key, smallImage)
            Me.listView.LargeImageList.Images.Add(key, largeImage)
        End If
        Return key
End Function

And then set your image getter for the column to it like:

Me.mainColumn.ImageGetter = AddressOf GetImageFromList
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文