Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 402
Ichibann Avatar asked Feb 25 '23 09:02

Ichibann


2 Answers

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?

like image 183
Ichibann Avatar answered Feb 27 '23 23:02

Ichibann


Check Padding property of your PictureBox

Set it 0

pictureBox1.Padding = new Padding(0);
like image 33
Javed Akram Avatar answered Feb 27 '23 22:02

Javed Akram