I use a loop to create a wpf document with four datagrids and other controls at runtime/by code. On the first cycle, the loop loads the window to creates all controls instances and populate the first datagrid, On the next cycles, the loop calls a sub to populates the second datagrid, etc. However, when I try to run the code I get the famous error: object reference not set to an instance of reference. Now the tricky part is that if I put a simple messagebox such as: Messagebox.Show("Populate"), the message is displayed and thereafter the code runs fine and populate all the controls as expected. Somehow, the messagebox serve as a trigger for something I am failing to locate. What am I missing here? I hope an astute fellow on object programming will locate the problem quite easily. Please help. I use vb.net. Thanks
↧