使用下面的函数加载数据的表之一有一个图像字段(BLOB),它在DataGridView上正确显示,但我想使列单元格布局缩放。我试过这个但是没有用:
For Each column As DataGridViewImageColumn _
In dgvAtivado.Columns
column.ImageLayout = DataGridViewImageCellLayout.Zoom
Next
我正在使用此功能填充DataGridView:
Public Sub show(dgv As DataGridView, ByRef connection As MySqlConnection, ByVal table_name As String, ByVal primary_key As String, ByVal query As String)
Dim adapter As New MySqlDataAdapter
Dim ds As DataSet = New DataSet
Try
adapter.SelectCommand = New MySqlCommand
adapter.SelectCommand.Connection = connection
adapter.SelectCommand.CommandText = query
ds.Clear()
connection.Open()
adapter.Fill(ds, table_name)
connection.Close()
dgv.AutoGenerateColumns = True
dgv.DataSource = ds
dgv.DataMember = table_name
dgv.Columns.Item(primary_key).Visible = False
dgv.ClearSelection()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
connection.Close()
End Try
End Sub