C# winform button动态加载背景图

来源:互联网 发布:腾讯剑雨江湖进阶数据 编辑:程序博客网 时间:2024/05/04 08:43
                 Button button = new Button();
                 button.Text=xmlNode.Attributes["text"].Value;
                button.Tag = tag;
                button.Location = new System.Drawing.Point(x, y);
                button.FlatStyle = FlatStyle.Flat;//样式  
                button.ForeColor = Color.Transparent;//前景  
                button.BackColor = Color.Transparent;//去背景  
                button.FlatAppearance.BorderSize = 0;//去边线  
                button.Image = Image.FromFile(@"D:\Pictures\" +xmlNode.Name+ ".jpg");
                button.Size = new Size(200,350);
                button.Click += new EventHandler(menuitem_Click);
                x += 300;
                this.Controls.Add(button);
0 0