首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

为啥无法透明啊

2013-03-27 
为何无法透明啊?如题,为什么啊button不是透明的?public Form1(){InitializeComponent()UseTransparentPro

为何无法透明啊?
如题,为什么啊button不是透明的?
       public Form1()
        {
            InitializeComponent();
            UseTransparentProperty();
        }

        private void UseTransparentProperty()
        {

            // Set up the PictureBox to display the entire image, and
            // to cover the entire client area.
            pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
            pictureBox1.Dock = DockStyle.Fill;

            try
            {
                // Set the Image property of the PictureBox to an image retrieved
                // from the file system.
                pictureBox1.Image =
                    Image.FromFile("C:\\Documents and Settings\\All Users\" +
                    "Documents\\My Pictures\\示例图片\\sunset.jpg");

                // Set the Parent property of Button1 and Button2 to the 
                // PictureBox.
                button1.Parent = pictureBox1;
                button2.Parent = pictureBox1;

                // Set the Color property of both buttons to transparent. 
                // With this setting the buttons assume the color of their
                // parent.
                button1.BackColor = Color.Transparent;
                button2.BackColor = Color.Transparent;

            }
            catch (System.IO.FileNotFoundException)
            {
                MessageBox.Show("There was an error." +


                    "Make sure the image file path is valid.");
            } 控件透明
[解决办法]

button1.FlatStyle = FlatStyle.Flat;

加上这一句就行了。。。

热点排行