简体   繁体   中英

problem with resources reading

i have a user-control 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;
        }
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM