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,612
  • 4
  • 38
  • 75
ComanderKai77
  • 460
  • 6
  • 14

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