i have a user-cont开发者_如何转开发rol designed as a button . The problem is that i can't display an image as the background.
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;
}
}
In this example, Network_Remote_Monitoring is my namespaceand but_verde.png is my desired background. The pop-up MessageBox always appears => not executing the try statements.
Can you find the problem?
public partial class inout_buton : UserControl
{
Bitmap bmp;
public inout_buton()
{
InitializeComponent();
try
{
bmp = new Bitmap(Network_Remote_Monitoring.Properties.Resources.but_verde);
}
catch
{
MessageBox.Show("it's bad");
}
this.BackgroundImage = bmp;
}
}
精彩评论