如何在 C# WinForm 中调整 DataGridView 的图像列的大小?

问题描述

我在 MysqL 中有一个表,我想在 c# winform 的 dataGridView 中显示这个表。

我的表包含文本值类型和图像 blob 类型。

当我填充数据网格时,它会正确填充并显示值和我的图像。

但以这种形式:

enter image description here

代码片段:

try
{
    MysqLConnection table_conn = new MysqLConnection("server=localhost; database=picg; user=root;password=Alora36318");
    string table_query = "SELECT * FROM personal_info";
    using (MysqLDataAdapter adpt = new MysqLDataAdapter(table_query,table_conn))
    {
        DataSet dset = new DataSet();
        adpt.Fill(dset);
        show_table.DataSource = dset.Tables[0];
        show_table.RowTemplate.Height = 120;

    }
    table_conn.Close();
}
catch(Exception ex)
{
    string create_query = "CREATE TABLE IF NOT EXISTS personal_info (ID INT AUTO_INCREMENT PRIMARY KEY,name TEXT,last_name TEXT,position TEXT,personal_id TEXT,part TEXT,personal_internal_id TEXT,photo_path MEDIUMBLOB)";
    MysqLConnection create_conn = new MysqLConnection("server=localhost; database=picg; user=root;password=Alora36318");
    MysqLCommand create_command = new MysqLCommand(create_query,create_conn);
    MysqLDataReader create_reader;
    create_conn.open();
    create_reader = create_command.ExecuteReader();
    create_conn.Close();

    MysqLConnection table_conn = new MysqLConnection("server=localhost; database=picg; user=root;password=Alora36318");
    string table_query = "SELECT * FROM personal_info";
    using (MysqLDataAdapter adpt = new MysqLDataAdapter(table_query,table_conn))
    {
        DataSet dset = new DataSet();
        adpt.Fill(dset);
        show_table.DataSource = dset.Tables[0];
        show_table.RowTemplate.Height = 120;

    }
    table_conn.Close();
}

如何拉伸图像?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)