Replies
Yeah it will be hard to troubleshoot this one.
Thanks for yor help.
[quote user="[Infragistics] Mike Saltzman"] Are you saying that the code in the ToolStripMenu is NOT setting the data source to null but somehow it's getting set to null, anyway?[/quote]
That's right, that's what is happening.
[quote user="[Infragistics] Mike Saltzman"]This seems to indicate that your ToolStripMenu is calling a method on your UserControl called CopySelection and it is this method that is calling BindGridData which ultimately ends up causing the null reference exception. [/quote]
There is an event handler attached to the TooStripMenu click event, only one. which calls the CopySelection method. It is here where I see that the DataSource of the grid is set to null. That's why I mentioned that if I try to re-assign the data source at this point (by calling the BindGridData), I get the null reference exception, which is very interesting because the Grid is not null obviusly and I can see that my object list is not null either, but still it breaks when I assign the object list to the DataSource property of the grid.
One more thing, the DisplayLayout property is also null.
I was curious to see if it had to do with using MDI forms. I removed the ToolStripMenu, and added buttons to the grid form, also I added the key shortcuts to these buttons and it now seems to work fine. Same code, nothing changed, except that the event handler responds now to the click of the buttons in the form instead of the click of the ToolStripMenu, which was in the MDI parent form.