I have a winform app which works correctly but I want to choose the column names, so I created the new columns.
When I open the application now, I have the blank manually generated columns, and then the autogenerated columns containing the data.
so I did:
dataGridView1.AutoGenerateColumns = false;
(on Form1 load)
and then:
List<Movimenti> source = dbo.RecuperaMovimenti(contoSelezionato);
dataGridView1.DataSource = source;
but I get an error:
object reference not set to an instance of an object.
I post some code which should help you to locate the problem:
When I select an item from my listbox, I want the datagridview to load the data for the selected user:
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
    DboInfo dbo = new DboInfo();
    try
    {
        contoSelezionato = listBox1.SelectedItem.ToString();
    }
    catch
    {}
         lblConto.Text = contoSelezionato;
         lblConto.Visible = true;
         lblTotale.Text = totale;
         lblTotale.Visible = true;
        try
        {
            List<Movimenti> source = dbo.RecuperaMovimenti(contoSelezionato);
            dataGridView1.DataSource = source;
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message.ToString());
        }
    }
dbo method for getting the data:
public List<Movimenti> RecuperaMovimenti(string contoSelezionato)
{            
    List<Movimenti> risultato = new List<Movimenti>();
    SQLiteConnection m_dbConnection = new SQLiteConnection();
        try
        {
            m_dbConnection = OpenConnection();
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message, ex);
        }
        SQLiteDataReader rdr;
        string sql = "SELECT id_movimento, data_movimento, descrizione_movimento, importo_movimento FROM movimenti WHERE nome_conto = '"+contoSelezionato+"'";
        SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection);
        rdr = command.ExecuteReader();
        while (rdr.Read())
        {
            Movimenti MOV = new Movimenti();
            MOV.id = (Int64)rdr["id_movimento"];
            //MOV.nome_conto = (string)rdr["nome_conto"];
            MOV.data = (string)rdr["data_movimento"];
            MOV.descrizione = (string)rdr["descrizione_movimento"];
            MOV.importo = Convert.ToInt32(rdr["importo_movimento"]);
            risultato.Add(MOV);
        }
        rdr.Close();
        m_dbConnection.Close();
        return risultato;
    }
edit:

that's a picture. My data doesn't go into my columns, it just creates auto generated columns
 
     
    