我怎样才能摆脱 Picturebox'边界?

发布于 2024-10-12 06:19:15 字数 989 浏览 2 评论 0原文

我有 PictureBox 并将其 BorderStyle 设置为 None 但我仍然在它周围有边框。我怎样才能摆脱它?

还有哪些细节?我的图像本身没有边框。 我使用代码

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

打开并显示图像:

图像为10x10。它们低于(800%)

原始:

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

及其显示方式:

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

血之狂魔 2024-10-19 06:19:15

应该做的是:

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

我不明白为什么当我从表单设计器将其设置为 None 时它不起作用。有人知道吗?

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?

半世晨晓 2024-10-19 06:19:15

检查 PictureBoxPadding 属性,

将其设置为 0

pictureBox1.Padding = new Padding(0);

Check Padding property of your PictureBox

Set it 0

pictureBox1.Padding = new Padding(0);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文