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);
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);
这篇博客介绍了如何在C# WinForm应用程序中动态创建Button控件,并为其设置透明背景以及从文件加载自定义背景图片。通过调整位置、大小和样式,使按钮更具个性化,同时在按钮点击事件中添加了处理方法。
1232

被折叠的 条评论
为什么被折叠?



