我有这样的DataGridView

我这样填充DataGridView

Dim cd As SqlCommandBuilder = New SqlCommandBuilder(adapter)
adapter = New SqlDataAdapter("select c.cid,c.CompanyName,d.dtId,d.dtName as Department,d.dtPhone as Phone,d.dtEmail as Email,d.empimage from CompanyMaster_tbl c join  DepartmentMaster_tbl d on c.Cid=d.cId order by cid", con.connect)

dt1 = New DataTable
bSource = New BindingSource
adapter.Fill(dt1) 'Filling dt with the information from the DB
bSource.DataSource = dt1
gv.DataSource = bSource
gv.Columns("cid").Visible = False
gv.Columns("dtId").Visible = False
Dim img As New DataGridViewImageColumn
img.HeaderText = "Image"
gv.Columns.Insert(6, img)

For i As Integer = 0 To gv.Rows.Count - 1
    gv.Rows(i).Cells(6).Value = gv.Rows(i).Cells(7).Value
Next
gv.Columns("empimage").Visible = False


如果DataGridViewImageColumn中有图像,我想增加行宽,并且图像应在该列中伸展。我必须在代码中进行哪些更改?

我想发布我的DataGridView图片,以使您更好地理解,但是发布该图片至少需要10个声誉。

最佳答案


gv.AutoSizeRowsModegv.AutoSizeColumnsMode

关于vb.net - 增加行大小取决于DataGridView中的图像,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21301658/

10-17 01:46