【发布时间】:2016-05-01 02:11:26
【问题描述】:
我的 TableLayoutPanel 有问题。 每个单元格都包含一个图片框,但是当我想显示我的 TableLayoutPanel(带有图片)时,图片之间会出现一些“空格”......我该如何解决它?
Please have a look at this to see my problem
这是我的代码:
private void button1_Click(object sender, EventArgs e)
{
_hauteurMap = Convert.ToInt32(numericUpDown1.Value);
_largeurMap = Convert.ToInt32(numericUpDown2.Value);
tableLayoutPanel1.ColumnCount = _largeurMap;
tableLayoutPanel1.RowCount = _hauteurMap;
tableLayoutPanel1.Controls.Clear();
int i, j;
for (i = 0; i < _hauteurMap; i++)
{
for (j = 0; j < _largeurMap; j++)
{
PictureBox pb = new PictureBox
{
Size = new Size(20, 20),
SizeMode = PictureBoxSizeMode.AutoSize
};
pb.Image = Image.FromFile("C:/Users/Sébastien/Documents/Visual Studio 2010/Projects/IsometricTileEngine_ITE/IsometricTileEngine_ITE/bin/Images/empty_tile.png");
tableLayoutPanel1.Controls.Add(pb, j, i);
}
}
}
【问题讨论】:
-
在这里使用
SizeMode = AutoSize完全没有意义。 -
我删除了它,但我没有改变任何东西......
标签: c# image picturebox spaces tablelayoutpanel