简体   繁体   中英

How can I get rid of Picturebox' border?

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?

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

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