我有一个按钮设计的用户控件。问题是我无法显示图像作为背景。资源阅读的问题
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