Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Horizontal Scrolling on a DataGridView unexpectedly runs Main() 1

Status
Not open for further replies.

PGO01

Programmer
Jan 8, 2008
156
GB
I have a DataGridView in a Windows application that has it's datasource set to a List at runtime.

The problem is when I scroll to the right to see the columns that are off-screen, the static Main() gets fired in the Program.cs and I get a NullReferenceException on the:

Code:
Application.Run(new MainForm());

Anyone know why this is???

Many thanks,
 
Your grid control is raising the exception. It may be trying to access an object that is null, has not been instantiated or doesn't exist. Something like a calculated field which only gets fired when displayed on screen.
 
You're right! Some of the values in the bound object are null... how can I handle this? Is there a property that I can set like a default value?

I would be happy to say if the value is null just display an empty string.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top