动态绘制按钮加载慢,如何解决?
/// <summary>
/// 动态绘制数组,增加按钮
/// </summary>
private void CreateArray()
{
string name;
int mapW = int.Parse(imgBox.Width.ToString());//地图宽度
int mapH = int.Parse(imgBox.Height.ToString());//地图高度
int ArrayXCount = getArrayCount(mapW, gridW);//数组X纬度
int ArrayYCount = getArrayCount(mapH, gridH);//数组Y纬度
for (int i = 0; i < ArrayXCount; i++)
{
for (int h = 0; h < ArrayYCount; h++)
{
Button myButton = new Button();
this.panel1.AutoScroll = true;
name = i.ToString() + "| " + h.ToString();//以X和Y取按钮名
myButton.Text = "0 ";
myButton.Name = name;
myButton.Height = gridH;//设置按钮高
myButton.Width = gridW;//设置按钮宽
myButton.Location = new Point(gridH * h, gridW * i);
&nb