我有一個按鈕設計的用戶控件。問題是我無法顯示圖像作爲背景。資源閱讀的問題
public partial class inout_buton : UserControl
{
Bitmap bmp;
public inout_buton()
{
InitializeComponent();
try
{
Stream s = this.GetType().Assembly.GetManifestResourceStream("Network_Remote_Monitoring.but_verde.png");
bmp = new Bitmap(s);
s.Close();
}
catch
{
MessageBox.Show("it's bad");
}
this.BackgroundImage = bmp;
}
}
在這個例子中,Network_Remote_Monitoring是我namespaceand but_verde.png是我所需的背景。彈出的MessageBox總是出現=>不執行try語句。
你能找到問題嗎?
您是否在屬性窗口中將「but_verde.png」圖片設置爲Embedded Resource? – jwaliszko 2010-10-30 16:51:23