I have to make an application in c# as a windows form.I chose to do a Lee Search between 2 points chosen by user and through walls put by user,and also to colour the path.
Here's is my project http://www.girlshare.ro/34729013. What it really pisses me off is the fact that sometimes this type of error "Object reference not set to an instance of an object" appears when nothing is wrong with my code.
For example in form1.cs, at newsearch()
function I declare a matrix of buttons and initialize it.At some time even that code caused object reference error,but now works,don't ask me why,I just rewrited it(ever if it was the same as before).
The problem is in function Lee_Click where I want to reproduce the path and color it.You can see that there is an if (if (a[i,j]!=null))
.I know that a[i,j]
is null beacuse when I run the program,it doesn't color the path.
What is wrong with it?I initialized the matrix of buttons....And maybe you could give me some advice about this error,I had it many times,but with luck or idk I managed to solve it.