记一次winfrom 面板改变背景图片


 this.panel1.BackgroundImage = Image.FromFile(@"D:\TestDemo\WindowsFormsApp2\WindowsFormsApp2\黑箭头.png");
            this.panel1.BackgroundImageLayout = ImageLayout.Stretch;
            this.panel1.Tag = "img1";
            teleTimer.Elapsed += (o,k)=> {
                if (this.panel1.Tag.ToString() != "img1")
                {
                    this.panel1.BackgroundImage = Image.FromFile(@"D:\TestDemo\WindowsFormsApp2\WindowsFormsApp2\黑箭头.png");
                    this.panel1.BackgroundImageLayout = ImageLayout.Stretch;
                    this.panel1.Tag = "img1";
                }
                else
                {
                    this.panel1.BackgroundImage = Image.FromFile(@"D:\TestDemo\WindowsFormsApp2\WindowsFormsApp2\红箭头.png");
                    this.panel1.BackgroundImageLayout = ImageLayout.Stretch;
                    this.panel1.Tag = "img2";
                }
            };
            teleTimer.Start();
posted @ 2022-11-30 18:31  沈先生爱猫咪  阅读(64)  评论(0编辑  收藏  举报