更改tableLayoutpanel的单元格(背景颜色和背景图像)

时间:2019-12-10 19:58:55

标签: c# tablelayoutpanel

问题1:

我想从Properties.Resource.image直接在TableLayoutPanel的单元格中添加图像。

lock

问题2:  我想更改单元格背景颜色的简单样式...

tableLayoutPanel1.Controls.Add(Properties.Resource.image,column,row);
  //cell backround should be covered with image

不是那个话题。我什至不能这样做。 How to set cell color in TableLayoutPanel dynamically?

1 个答案:

答案 0 :(得分:0)

您可以在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;
}