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 8961053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:47:54+00:00 2026-06-15T15:47:54+00:00

I have two forms Form 1 and Form 2. Form 2 is inheriting from

  • 0

I have two forms Form 1 and Form 2.

Form 2 is inheriting from Form 1. In Form 1 I have a method on_Paint for a particular panel, in which I am drawing an image. Since Form 2 is inheriting from Form 1, the panel is being shown as painted before I even run the program (on the design of Form 2).

The problem is, that now I need to paint some things over this image after the image is painted in Form 2. How can I make this possible?

This is some code to make the problem more clear.

// This is Form 1 on_Paint method

private void grid_Paint(object sender, PaintEventArgs e)
{
    Image img = Image.FromFile(resourcesPath+ "grid.fw.png");

    gridGraphics = grid.CreateGraphics(); 
    gridGraphics.DrawImage(img, 0, 0, 650, 550);
}

// This is the method which I want to be invoked after the grid is painted.. This is located in Form 1:

public void paintSprites(int row, int column, int value)
{
     int yLoc = 0;
     int xLoc = 0;
     Graphics g = grid.CreateGraphics();

     switch (row)
     {
         case 0: yLoc = 435; break;
         case 1: yLoc = 355; break;
         case 2: yLoc = 275; break;
         case 3: yLoc = 195; break;
         case 4: yLoc = 115; break;
         case 5: yLoc = 35; break;
     }

     switch (column)
     {
         case 0: xLoc = 35; break;
         case 1: xLoc = 120; break;
         case 2: xLoc = 205; break;
         case 3: xLoc = 290; break;
         case 4: xLoc = 375; break;
         case 5: xLoc = 460; break;
         case 6: xLoc = 545; break;
     }

     if (value == 1)
     {
         g.DrawImage(red, xLoc, yLoc, 65, 65);
     }
     else g.DrawImage(gold, xLoc, yLoc, 65, 65);
 }

This method is located in Form 2 and calls the method above:

public void checkWhichToPaint()
{
    for (int i = 0; i < ROWS; i++)
    {
        for (int j = 0; j < COLUMNS; j++)
        {
            if (gridMap[i, j] != 0)
            {
                paintSprites(i, j, gridMap[i, j]);
            }
        }
    }
}

and I am calling the method checkWhichToPaint() after creating a new instance of Form 2 and Showing it:

Tournament tournament = new Tournament();
tournament.LoadGame();
tournament.Show();  
tournament.checkWhichToPaint();

where can I call this method such as it is painted after the grid_Paint is invoked?

Thanks for your help 🙂

  • 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-15T15:47:55+00:00Added an answer on June 15, 2026 at 3:47 pm

    Override the paint method in the second form and call base paint method before you run your form 2 code.

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

Sidebar

Related Questions

I have two form classes inheriting from a common base. One of the forms
Basically I have two forms The first form Is a simple select box which
I have two forms, one with a button 'Add' which loads the second form
I have two forms Form1 and Form2. Form2 is inheriting from Form1. What I
I have two forms. The first form is the mainForm, this never goes anywhere.
I have created two forms in my Windows Application. One Form acts as a
I have two links with classes (login-form and register-form) relevant to their target forms
I have an application that consists of two forms. One form displays data returned
I have a formset that have two forms. forms: class PresClinicForm(forms.Form): _names = list(PresClinic.objects.values_list('pres_clinic_id',
I have two forms, form A and form B. These forms must differ in

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.