开发者

How can I get rid of Picturebox' border?

开发者 https://www.devze.com 2023-02-05 10:16 出处:网络
I have PictureBox and I set its BorderStyle to None but I\'m still getting a border around it. How can I get rid of that?开发者_StackOverflow社区

I have PictureBox and I set its BorderStyle to None but I'm still getting a border around it. How can I get rid of that?

开发者_StackOverflow社区

What more details? My Image doesn't have borders itself. I use the code

    private void btnLoad_Click(object sender, EventArgs e)
    {

        if (dgOpenFile.ShowDialog() == DialogResult.OK)
        {
            try
            {
                img = new Bitmap(dgOpenFile.FileName);

                picture.Size = img.Size;
                picture.Image = img;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }

To open and display the image:

Image is 10x10. They are below (at 800%)

original:

http://img695.imageshack.us/img695/2409/originallu.png

and how it is displayed:

http://img209.imageshack.us/img209/7088/displayed.png


What should be done is:

    private void Form1_Load(object sender, EventArgs e)
    {
        picture.BorderStyle = BorderStyle.None;
    }

I don't understand why it doesn't work when I set it to None from Form Designer. Anyone knows?


Check Padding property of your PictureBox

Set it 0

pictureBox1.Padding = new Padding(0);
0

精彩评论

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