Hello, I'm learning and I want to know the best way of doing this.
I have a NxM square of inherited pictureboxes dinamically created:
//in the form
public frmMain(){
for(int i=0;i<N;i++){
for(int j=0;j<M;j++){
this.Controls.Add(new Cuadradito(i,j,number));
}
}
}
//the point class
public class Cuadradito:PictureBox{
public Cuadradito(int xCoord, int yCoord, int num){
state=num;
}
private void Cuadradito_MouseDown(object sender, MouseEventArgs e) {
state=some_value;
}
}
The number passed is the state of this point.
In the MouseDown event I change the state of this point and I need to change the states of the adjacent points.
Mi question is how can I do this. I have the N and M values of the points I need to change the state but the MouseDown event occurs only in the instance of "Cuadradito" clicked, so how do I tell the rest of the points to change states. I mean, there is no comunication between instances of this class. I can add an event, but I don't know if this is the best way to do it (an event that fires after the MouseDown, like ChangeState).
Thanks, hope you can help.
RonQ.