private void SetPiece(int colum)
{
Point[,] pointArray = new Point[colum, colum];
for (int i = 0; i < colum; i++)
{
for (int j = 0; j < colum; j++)
{
pointArray[i, j].X = (2 * i + 1) * colum / 2;
pointArray[i, j].Y = (2 * j + 1) * colum / 2;
}
}
Image img = new Bitmap("images/black.png");
for (int i = 0; i < colum; i++)
{
for (int j = 0; j < colum; j++)
{
PictureBox picBtn = new PictureBox();
picBtn.Text = i.ToString() + j.ToString();
picBtn.Tag = pointArray[i, j];
picBtn.Click += new System.EventHandler(picBtn_Click);
picBtn.Location = pointArray[i, j];
picBtn.Image = img;
this.panelMain.Controls.Add(picBtn);
}
}
}代码批量添加picturebox矩阵 colum X colum
这样只显示左上角一个picturebox,成功加载了图片,但是其余都没有
colum=4,用foreach遍历也有16个控件,不知道是重叠了还是什么原因,求解
解决方案 »
- the given key was not present in the dictionary
- 自定义struct转换问题
- 请问WPF一定要手写XAML吗?
- C# WinForm中TextBox的外觀
- 多线程的问题,高手请教
- 有一个文件里面的内容是简体字,我想用一个程序将里面的简体字全部转为繁体字,怎么做啊!
- 数组中的指定列显示在datagridview中
- 如何将绑定的javascript效果在.net中运行出来
- 用C#寫的東西,佔内存都比較多,大家在這方面有什麽建議?
- 我记得以前有用C#开发的类似于VS.NET左边工具箱的那种代码,但找不到了.:(
- listView 动态分列 怎么整 谢谢
- nfc 读取卡片,android中有个MifareClassic(Tag tag)的类有个a.getSak()方法可以拿到个东西,是0x01这样的
for (int i = 0; i < colum; i++)
{
for (int j = 0; j < colum; j++)
{
pointArray[i, j].X = (2 * i + 1) * colum / 2;
pointArray[i, j].Y = (2 * j + 1) * colum / 2;
}
}把pointArray[i, j].X = (2 * i + 1) * colum / 2;
pointArray[i, j].Y = (2 * j + 1) * colum / 2;
的cloum改成40之后,怎么也只是一列,不是矩阵的那个效果呢