0
如何在按鈕數組的按鈕上添加圖像?C#如何在按鈕陣列按鈕上添加圖像
Button[] mybuttons = new Button[] {Button1,Button2}; //My button array
mybuttons[1].image=new Bitmap("Click.jpg"); ///Gives Error
「System.Web.UI.WebControls.Button」不包含「圖像」和沒有擴展方法「圖像」接受型的第一參數「的定義System.Web.UI.WebControls.Button '可以找到(你是否缺少使用指令或程序集引用?)
但是,我需要使用沒有imagebutton屬性的按鈕數組。 – 2012-04-16 23:25:34
然後恐怕你運氣不好,Button類在你編寫Windows Forms應用程序時只有一個Image屬性。 Windows窗體應用程序使用此按鈕類,http://msdn.microsoft.com/en-us/library/system.windows.forms.button.aspx。您不能在ASP.NET中使用System.Windows.Forms.Button類。在ASP.NET Web應用程序中,Button類來自System.Web.UI.WebControls,根本不實現Image屬性。 – JamieSee 2012-04-17 15:56:41