gpt4 book ai didi

vb.net - 如何在datagridview单元格中添加图像和文本

转载 作者:行者123 更新时间:2023-12-04 22:01:58 25 4
gpt4 key购买 nike

实际上我想根据我的要求自定义 Datagridview 单元格。我必须将文本和图像添加到特定列的 Datagridview 行。看下图

enter image description here

谁能帮我举个例子?谢谢。

最佳答案

试试这个

Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
DataGridView1.ColumnCount = 3
DataGridView1.Columns(0).Name = "Product ID"
DataGridView1.Columns(1).Name = "Product Name"
DataGridView1.Columns(2).Name = "Product_Price"

Dim row As String() = New String() {"1", "Product 1", "1000"}
DataGridView1.Rows.Add(row)
row = New String() {"2", "Product 2", "2000"}
DataGridView1.Rows.Add(row)
row = New String() {"3", "Product 3", "3000"}
DataGridView1.Rows.Add(row)
row = New String() {"4", "Product 4", "4000"}
DataGridView1.Rows.Add(row)

Dim img As New DataGridViewImageColumn()
Dim inImg As Image = Image.FromFile("Image Path")
img.Image = inImg
DataGridView1.Columns.Add(img)
img.HeaderText = "Image"
img.Name = "img"

End Sub
End Class

关于vb.net - 如何在datagridview单元格中添加图像和文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14476558/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com