You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在VB.NET的DataGridViewImageColumn中移除空图像(含新行)

VB.NET中移除DataGridView图像列空图像的实现方法

在VB.NET开发中,可通过自定义图像单元格的方式移除DataGridView图像列中的空图像,以下是具体实现代码及效果对比:

代码示例

Private Sub TextBox1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles TextBox1.KeyPress

    If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Enter) Then
        item.Add(New item With {
            .CodeProduct = TextBox1.Text
        })
        Grid.Bind(item)
        TextBox1.Clear()
    End If
End Sub

Public Class item
    Public Property No() As Integer
    Public Property CodeProduct() As String
    Public Function GetAvatar() As DataGridViewAvatar
        Return New DataGridViewAvatar() With {
            .Value = CType(Me.CodeProduct, String),
            .Icon = Image.FromFile("money.png")
        }
    End Function

效果展示

  • 移除空图像的目标效果:
    移除DataGridView图像列空图像

  • 使用自定义图像单元格前(存在空图像):
    使用自定义图像单元格前

  • 使用自定义图像单元格后(空图像已移除):
    使用自定义图像单元格后

内容的提问来源于stack exchange,提问作者roy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.18 18:03:20