Datagridview index out of range after form reload
Posted on 2011-02-21
I have 2 datagridviews on a form. They look almost exactly alike except one is a "Manager View" and the other is a "National View". Manager View shows data data for all his employees. National View shows all the manager's data. In national view, if I click the managers name, it shows manager view with his emplyees. If I click an employee in Manager view, it closes the form and displays the detail for the employee. Here's the weird problem...... If I never go to national view I can click an employee to display his details, come back and do it again without issue. However, if I display national view; click a manager; then click and employee to display the emplyee's detail (it closes the form); then open the form again, I get an index out of range trying to modify column header text. The grid that is supposed to diplay first during form load is the Manager View. The manager view has Zero columns at this point (albeit the reason I'm getting the index out of range). Why would there be no columns? I didn't remove them. I'm creating a New form (Dim F as SomeForm = New SomeForm) when I re-display the Manager/National View form.