C#如何同时将已知路径的多张图片分别添加到多个动态生成的按钮上?

2025-02-25 09:52:19
推荐回答(1个)
回答1:

private System.Windows.Forms.Button button1;
//按你自己的要求动态实例化按钮控件
this.button1.Location = new System.Drawing.Point(807, 440);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 8;
this.button1.Text = "button1";
//添加指定路径图片值按钮控件
string strPath="X:\xx\xx.xxx"; //图片路径
this.button1.Image = new Bitmap(strPath);