private void MoveMatrice_Event(object sender, MouseEventArgs e) { int nr = 0, i = 0, j = 0; Button b = (Button)sender; nr = Convert.ToInt32(b.Name.Substring(6, b.Name.Length - 6)); i = nr / 20; j = nr % 20; view.setIndexLoc(i, j); }