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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:00:58+00:00 2026-06-05T02:00:58+00:00

I’m working in a C# Forms application. I had dragged and dropped a table

  • 0

I’m working in a C# Forms application.

I had dragged and dropped a table layout panel, into the windows, and the proceeded to add components dynamically Outside de Form1.Designer.cs auto generated file, the code is in the Form1.cs file.

There I add with a couple of for loops all the content that should fill the layout table, this one done successfully.

The problem now is that I want to also want to dynamically create the table layout, so what I did was just copying and pasting the auto-generated code out of the designer file and deleted the d&d table layout from the [design].

This is what I did for the other components and it has worked seamlessly, and now, for some reason, this doesn’t what to work.

The expected result would be the (invisible layout panel) displaying all the imageboxes inside it.

The output, simply shows an empty window.

The code is as follows:

private void paintLayoutTableOnScreen()
    {
        this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
        this.SuspendLayout();
        // 
        // tableLayoutPanel
        // 
        this.tableLayoutPanel.ColumnCount = 6;
        this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 16.66667F));
        this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 16.66667F));
        this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 16.66667F));
        this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 16.66667F));
        this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 16.66667F));
        this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 16.66667F));
        this.tableLayoutPanel.Location = new System.Drawing.Point(12, 12);
        this.tableLayoutPanel.Name = "tableLayoutPanel";
        this.tableLayoutPanel.RowCount = 5;
        this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F));
        this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F));
        this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F));
        this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F));
        this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F));
        this.tableLayoutPanel.Size = new System.Drawing.Size(992, 460);
        this.tableLayoutPanel.TabIndex = 0;
        this.tableLayoutPanel.Paint += new System.Windows.Forms.PaintEventHandler(this.tableLayoutPanel_Paint);
    }

And just below:

private System.Windows.Forms.TableLayoutPanel tableLayoutPanel;

So, I’m certain that the problem is here since it was printing to screen the imageboxes before I changed the place of the code. So the problem should be there, but just in case:

I am calling paintLayoutTableOnScreen() the following way:

public Form1()
    {
        InitializeComponent();
        paintLayoutTableOnScreen();
        paintTablesInScreen();//This was already there and worked just fine.
    }

paintTablesInScreen() does the following:

private void paintTablesInScreen()
    {
        for (int i = 0; i < Info.NumberOfColumns; i++)
        {
            for (int j = 0; j < Info.NumberOfRows; j++)
            {
                drawTable(i, j);

            }
        }
    }

and drawTable():

private void drawTable(int column, int row)
    {
        int tableNumber = Info.TableNumber(column, row);

        this.pictureBox1 = new System.Windows.Forms.PictureBox();
        this.pictureBox1.Image = Image.FromFile("C:\\Users\\Trufa\\Documents\\Visual Studio 2010\\Projects\\Viernes 7\\table.png");
        this.pictureBox1.Location = new System.Drawing.Point(3, 3);
        this.pictureBox1.Name = "pictureBox" + tableNumber.ToString();
        this.pictureBox1.Tag = tableNumber.ToString();
        this.pictureBox1.Size = new System.Drawing.Size(128, 86);
        this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
        this.pictureBox1.TabIndex = 0;
        this.pictureBox1.TabStop = false;
        this.pictureBox1.Click += new EventHandler(AnyPictureBoxClickHandler);

        this.pictureBox1.Paint+=new PaintEventHandler((sender, e) =>
        {
            e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
            e.Graphics.DrawString(tableNumber.ToString(), Font, Brushes.Black, 58, 20);
        });


        this.tableLayoutPanel.Controls.Add(this.pictureBox1, column, row);
    }
  • 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-05T02:01:00+00:00Added an answer on June 5, 2026 at 2:01 am

    You are not adding your TableLayoutPanel to the Controls of the form. I.e. you miss:

    this.Controls.Add(this.tableLayoutPanel);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
Thanks in advance for your help. I have a need within an application to
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.