简体   繁体   English

如何摆脱Picturebox的边框?

[英]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. 我有PictureBox ,并将其BorderStyle设置为None但周围仍然有边框。 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. 图片为10x10。 They are below (at 800%) 他们低于(800%)

original: 原版的:

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

and how it is displayed: 以及显示方式:

http://img209.imageshack.us/img209/7088/displayed.png 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. 我不明白为什么将它从Form Designer设置为None时不起作用。 Anyone knows? 有谁知道?

Check Padding property of your PictureBox 检查PictureBox Padding属性

Set it 0 设置为0

pictureBox1.Padding = new Padding(0);

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

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