Problems testing refferences of labels in a control array.
Hi All,
I have a two dimentional array of type lable. I am using this array to create a grid (I eventualy gave up on the datagrid as it just wouldn't do the stuff I wanted without an auful lot of complex customisation). During the grids life time, rows will be added and removed.
My problem is this:
Problem 1: When the grid is first created I need to be able to test each cell in the array to see if I need to create (call new) on the lable and add it it too the controls on the user control.
My current solution is this (which I am not happy with due to problem 2):
Try to set a property and if the "refference not set to an instance of an object" error is thrown, catch it and create the lable.
Problem 2: Later on after rows have been added and removed and added again some rows (the ones deleted I think) are not throwing the error (or any error) and I cant therefore add them back on to the user control. I seem to be able to set there properties but they just can't be seen on the control.
I remove the labels with the following code:
Me.Controls.Remove(Labels(colIndex, i)) Labels(colIndex, i).Dispose() |
Hope this makes sense,
Danny

