简体   繁体   中英

DataGridView Image Column is throwing an Argument Exception: Parameter not valid

I am trying to load the data from MySQL database where the images are also placed in my table but when the form loads it gives the exception:

Any help would be appreciated

private void DealSuggestion_Load(object sender, EventArgs e)
{
    try
    {
        status.Items.Add("active");
        status.Items.Add("inactive");
        id.Visible = false;
        label7.Text = "";
        conn.Open();
        MySqlCommand cm = new MySqlCommand();
        string query = "SELECT * from dealSuggestion where Status='inactive' LIMIT 8";
        cm.CommandText = query;
        cm.Connection = conn;
        MySqlDataAdapter da = new MySqlDataAdapter(cm);
        DataTable dt = new DataTable();
        da.Fill(dt);
        dataGridView1.DataSource = dt;
        conn.Close();
    }
    catch (Exception ex)
    {
        MessageBox.Show("Error" + ex);
    }
}

DataGridViewImageColumn dgvimgcol = new DataGridViewImageColumn();
Check this out https://www.c-sharpcorner.com/UploadFile/009464/insert-images-into-datagridview-in-windows-application-using/

Columns in datagridview are consider as string so you need to create an imagecolumn instead of binding it

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM