我有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
如果DataGridView
中有ImageColumn
图像,我想增加行宽,图像应该在该列中拉伸。我必须在代码中做出哪些更改?
我想发布我的DataGridView
图片以便您更好地理解,但我需要至少10个声望来发布图片。
答案 0 :(得分:0)
使用
gv.AutoSizeRowsMode
和gv.AutoSizeColumnsMode