问题1:
我想直接从Properties.Resource.image中将图像添加到TableLayoutPanel的单元格中。
tableLayoutPanel1.Controls.Add(Properties.Resource.image,column,row);
//cell backround should be covered with image
问题2:我想更改单元格背景颜色的简单样式...
tableLayoutPanel1.Position(column,row).backroundcolor=Color.Red;
不是那个话题。我什至不能这样做。How to set cell color in TableLayoutPanel dynamically?
您可以在TableLayoutPanel中托管一个PictureBox以显示图像或重置其背景色。
private void Form1_Load(object sender, EventArgs e)
{
PictureBox pictureBox = new PictureBox();
this.tableLayoutPanel1.Controls.Add(pictureBox, 1,1);
// Set background image
pictureBox.Image = Properties.Resources.TestImage;
// Set background color
//pictureBox.BackColor = Color.Red;
}