1
我試圖動態地設置按鈕的圖像的大小這樣如何在c#中動態設置按鈕圖像的大小?
foreach (DataRow row in dlCatObj.ReadCat().Rows)
{
Button btnObj = new Button();
int btnID = Convert.ToInt32(row["CAT_ID"]);
string btnName = row["CAT_NAME"].ToString();
if (!DBNull.Value.Equals(row["CAT_IMAGE"]))
{
photo = (byte[])(row["CAT_IMAGE"]);
btnObj.Image = (ByteToImage(photo));
btnObj.Image.Size = new size(100, 80); //Here I have a Problem
}
btnObj.Name = btnID.ToString();
btnObj.Text = btnName;
btnObj.Size = new System.Drawing.Size(150, 150);
this.plCategory.Controls.Add(btnObj);
}
,但我不明白我怎麼做到這一點的方式。請指導我的方式?