首页 > 解决方案 > tablelayoutpanel 不会改变背景图片

问题描述

图片名称是从ini文件中加载的,第一次设置背景没有任何问题。但是,当它根据动作从ini文件中加载另一个图像时,它不会设置不同的背景。

 var parser = new FileIniDataParser();
 IniData data = parser.ReadFile("configuration.ini");

 int panelRow = GetMyClass.toInt(data[config_PanelCount]["rowCount"]);
 int panelColl = GetMyClass.toInt(data[config_PanelCount]["collCount"]);
 string bckGround = data[config_PanelCount]["background"];
 tableStolovi.Controls.Clear();
 tableStolovi.BackgroundImage = null;
            

 string appPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
 Image bck = Image.FromFile(appPath + "\\" + bckGround);
 tableStolovi.BackgroundImage = bck;
 tableStolovi.BackgroundImageLayout = ImageLayout.Stretch;

如何每次为tablelayoutpanel设置背景

标签: c#windowswinformstablelayoutpanel

解决方案


您可以在设置新背景后尝试刷新 tableLayoutPanel。

tableStolovi.Refresh();

推荐阅读