Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9164071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:35:36+00:00 2026-06-17T14:35:36+00:00

I am supposed to load an image from a file and this image should

  • 0

I am supposed to load an image from a file and this image should cover 80% of pictureBox and then draw something on it… With loading there is no problem, but trying to draw anything on it drops an error that has an unproper parameter (g.FillRectangle…).

I found on stack advice to refresh pictureBox, but it changes nothing…
And i have no idea how to solve this…

private void button1_Click_1(object sender, EventArgs e)
{
    pictureBox1.Width = (int)(Width * 0.80);
    pictureBox1.Height = (int)(Height * 0.80);

    // open file dialog 
    OpenFileDialog open = new OpenFileDialog();
    // image filters
    open.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp";
    if (open.ShowDialog() == DialogResult.OK)
    {
        // display image in picture box
        pictureBox1.Image = new Bitmap(open.FileName);
        // image file path
        //  textBox1.Text = open.FileName;
        g.FillRectangle(Brushes.Red, 0, 0, 20, 50);
        pictureBox1.Refresh();
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T14:35:37+00:00Added an answer on June 17, 2026 at 2:35 pm

    Use Graphics.FromImage or Control.CreateGraphics methods for draw on your image:

    var img = new Bitmap(open.FileName);
    using (Graphics g = Graphics.FromImage(img))
    {
        g.FillRectangle(Brushes.Red, 0, 0, 20, 50);  
    }
    pictureBox1.Image = img;
    

    or draw directly on PictureBox by Paint event (for example by using Anonymous Methods):

    pictureBox1.Paint += (s, e) => e.Graphics.FillRectangle(Brushes.Red, 0, 0, 20, 50);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .php file that's supposed to load an image for display in
Supposed a text file named name.txt . there are some contents as the following
I am working on a script that downloads a file from Dropbox, supposed to
I have a banner (XML_Banner.swf) that is supposed to load and rotate images from
I'm loading a big jpeg file from a url using an InputStream from a
Suppose I load an array of bytes as RGB from a given file. I've
I have a WPF window that is supposed to load two vector images from
I have a jsonstore that is supposed to load a user's information. I have
I know you're supposed to only load log4j properties once, so what is standard
How to load javascript contents using php. Suppose when php saves a file using,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.