public void random() { textBox1.Text = ""; ListBox.ObjectCollection list = ListBox1.Items; Random rng = new Random(); int n = list.Count; //begin updating ListBox1.BeginUpdate(); while (n > 1) { n -= 1; int k = rng.Next(n + 1); object value = list[k]; list[k] = list[n]; list[n] = value; } ListBox1.EndUpdate(); ListBox1.Invalidate(); { string values = ListBox1.Items[0].ToString(); string[] tokens = values.Split(','); int[] convertedItems = Array.ConvertAll <string, int>(tokens, int.Parse); Button1.Location = new Point(convertedItems[0], convertedItems[1]); } { string values = ListBox1.Items[1].ToString(); string[] tokens = values.Split(','); int[] convertedItems = Array.ConvertAll <string, int>(tokens, int.Parse); Button2.Location = new Point(convertedItems[0], convertedItems[1]); } { string values = ListBox1.Items[2].ToString(); string[] tokens = values.Split(','); int[] convertedItems = Array.ConvertAll <string, int>(tokens, int.Parse); Button3.Location = new Point(convertedItems[0], convertedItems[1]); } { string values = ListBox1.Items[3].ToString(); string[] tokens = values.Split(','); int[] convertedItems = Array.ConvertAll <string, int>(tokens, int.Parse); Button4.Location = new Point(convertedItems[0], convertedItems[1]); } { string values = ListBox1.Items[4].ToString(); string[] tokens = values.Split(','); int[] convertedItems = Array.ConvertAll <string, int>(tokens, int.Parse); Button5.Location = new Point(convertedItems[0], convertedItems[1]); } { string values = ListBox1.Items[5].ToString(); string[] tokens = values.Split(','); int[] convertedItems = Array.ConvertAll <string, int>(tokens, int.Parse); Button8.Location = new Point(convertedItems[0], convertedItems[1]); } { string values = ListBox1.Items[6].ToString(); string[] tokens = values.Split(','); int[] convertedItems = Array.ConvertAll <string, int>(tokens, int.Parse); Button7.Location = new Point(convertedItems[0], convertedItems[1]); } { string values = ListBox1.Items[7].ToString(); string[] tokens = values.Split(','); int[] convertedItems = Array.ConvertAll <string, int>(tokens, int.Parse); Button6.Location = new Point(convertedItems[0], convertedItems[1]); } { string values = ListBox1.Items[8].ToString(); string[] tokens = values.Split(','); int[] convertedItems = Array.ConvertAll <string, int>(tokens, int.Parse); Button9.Location = new Point(convertedItems[0], convertedItems[1]); } }