读心术动态加载控件遇到的问题
读心术动态加载图片和控件,但是点击button按钮却无法实现图片刷新,再者如何实现是9的倍数的图片加载的都相同?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace _111
{
   public partial class Form1 : Form
   {
   public Form1()
   {
   InitializeComponent();
   }
   private void Form1_Load(object sender, EventArgs e)
   {
   Button myButton = new Button();
   myButton.Text = "重试";
   myButton.Height = 40;
   myButton.Width = 60;
   myButton.Top = 15;
   myButton.Left = 100;
   myButton.Click += new EventHandler(myButton_Click);
   this.Controls.Add(myButton);
   }
   private void myButton_Click(object sender,EventArgs e)
   {
   Random myRandom = new Random();
   int top = 60, left = 60;
   int top1 = 100, left1 = 75;
   Label[] myLabel = new Label[10];
   int s = 1;
   PictureBox[] myPicturebox = new PictureBox[10];
   for (int i = 0; i < 10; i++)
   {
   for (int j = 0; j < 10; j++)
   {   
   myPicturebox[j] = new PictureBox();//初始化picturebox的新实例
   myPicturebox[j].Image = System.Drawing.Bitmap.FromFile(@"icon\" + myRandom.Next(1, 40) + ".bmp");
   myPicturebox[j].Width = 40;
   myPicturebox[j].Height = 40;
   myPicturebox[j].Top = top;
   myPicturebox[j].Left = left;
   this.Controls.Add(myPicturebox[j]);
   left += 60;
   string str = s.ToString();
   myLabel[j] = new Label();//初始化类的新实例   
   myLabel[j].Text = str;
   myLabel[j].Width = 40;
   myLabel[j].Height = 20;
   myLabel[j].Top = top1;
   myLabel[j].Left = left1;
   this.Controls.Add(myLabel[j]);
   left1 += 60;
   s = s + 1;
   }
   top1 += 60;
   left1 = 75;
   top += 60;
   left = 60;
   }
   }      
   }
}
------解决方案--------------------
问题还未解决么? Random 声明不应该放在button里面   程序只new一次Random 就够了  new多了会出乱子