2

I'm using this code:

DataTable table = new DataTable();
table.Columns.Add("Title");
dataGridView1.DataSource = table;

to populate my dataGridView but I get a null reference exception when I set the datasource.

PRVS
  • 1,502
  • 4
  • 28
  • 65
ComanderKai77
  • 401
  • 4
  • 11

1 Answers1

4

Your dataGridView1 is most likely a NULL reference. To verify, set a breakpoint on the line and when you hit it, hover your mouse over dataGridView1.

Kai van Lopik
  • 246
  • 1
  • 4