Windows Develop Bookmark and Share   
 index > Windows Forms General > Empty grid but dataSet has data...
 

Empty grid but dataSet has data...

I am trying to load a child grid based on a RowEnter event of the parent grid. My problem is that the RowEnter event seems to be firing before the grid is loaded and the following code keeps generating an "Object Reference not set to an instance of an object. I tried to trap for the row.count in the dataset, but apparently, there are rows there even though the grid is not yet seeing them. I can't find a property to trap on for this problem. I could also grab the current table/cell in the dataset, but I can't find the syntax for that either. Suggestions?

MessageBox.Show(gridContests["ContestID", gridContests.CurrentCell.RowIndex].Value.ToString());
  • Moved byOmegaManMVPFriday, May 22, 2009 7:23 PM (From:Visual C# General)
  •  
cboshdave  Friday, May 22, 2009 6:44 PM
I had the same problem with a DataGridView. The problem was EditMode set to DataGridViewEditMode.EditOnEnter. Try to set another EditMode, set the data, set EditMode back to DataGridViewEditMode.EditOnEnter. It's a workaround but it fixed my problem.

Hope this helps
Florian Reischl  Friday, May 22, 2009 7:01 PM
I had the same problem with a DataGridView. The problem was EditMode set to DataGridViewEditMode.EditOnEnter. Try to set another EditMode, set the data, set EditMode back to DataGridViewEditMode.EditOnEnter. It's a workaround but it fixed my problem.

Hope this helps
Florian Reischl  Friday, May 22, 2009 7:01 PM

You can use google to search for other answers

Custom Search

More Threads

• Keypresses in picture box
• how to force arabic keyboard?
• Dispose and custom components
• Send Key Strokes to a specific window handle.
• Help.ShowHelp locking up
• How to search a table in a dataSet for value?
• MouseMove: Cursor "slips off / drops" control
• Dynamically referencing a Label Control
• Dynamic Entry Form
• Any situations where the NotifyIcon.ShowBalloonTip(...) WONT actually show the balloon?