开发者

problem with resources reading

开发者 https://www.devze.com 2023-01-22 22:59 出处:网络
i have a user-cont开发者_如何转开发rol designed as a button . The problem is that i can\'t display an image as the background.

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;
        }
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消