繁体   English   中英

资源阅读问题

[英]problem with resources reading

我有一个设计为按钮的用户控件。 问题是我无法将图像显示为背景。

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是我的命名空间,而but_verde.png是我想要的背景。 弹出的MessageBox总是显示=>不执行try语句。

你能找到问题吗?

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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