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

  • Home
  • SEARCH
  • 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 8624039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:25:37+00:00 2026-06-12T07:25:37+00:00

I am currently working with a pictureBox. I am having difficulties drawing a grid

  • 0

I am currently working with a pictureBox. I am having difficulties drawing a grid over the picture box that is approximately the size of 2 x 2 squares. Now the code below is only giving me a line drawn across. How can I proplery draw a full grid on top of the pictureBox?

CODE:

private Graphics g1;

    public Form1()
    {
        InitializeComponent();


        pictureBox1.Image = new Bitmap(500, 500);
        g1 = Graphics.FromImage(this.pictureBox1.Image);
        Pen gridPen = new Pen(Color.Black, 2);
        g1.DrawLine(gridPen, 0, 0, 100, 100);

    }

This what I would like to accomplish:
enter image description here

  • 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-12T07:25:38+00:00Added an answer on June 12, 2026 at 7:25 am

    I found this question:
    Efficiently draw a grid in Windows Forms

    Here is the gist of it:

    private void pictureBox1_Paint(object sender, PaintEventArgs e)
            {
                Graphics g = e.Graphics;
                int numOfCells = 200;
                int cellSize = 5;
                Pen p = new Pen(Color.Black);
    
                for (int y = 0; y < numOfCells; ++y)
                {
                    g.DrawLine(p, 0, y * cellSize, numOfCells * cellSize, y * cellSize);
                }
    
                for (int x = 0; x < numOfCells; ++x)
                {
                    g.DrawLine(p, x * cellSize, 0, x * cellSize, numOfCells * cellSize);
                }
            }
    

    Customize accordingly

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently working with converting SQLException error messages into messages that are more useful for
Im currently working on a game that uses multi touch to apply zoom to
Am currently working on an application that requires users to submit posts and comments
I'm working with an application that utilizes the Google Weather API, right now I
Am currently working on a site that uses a lot of cfwindow objects and
Im currently working on a project that requires the following. I need to be
I'm currently working on a game engine in java, however I'm having preformance issues
I am using a custom control that inherits from a picture box to simulate
Im currently working on a c# project that uses another .net library. This library
I'm currently working on a program in WinForms that will require a lot of

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.