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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:53:34+00:00 2026-06-11T20:53:34+00:00

I’m creating a table layout panel to display the values from a dictionary, but

  • 0

I’m creating a table layout panel to display the values from a dictionary, but the table layout panel keeps cutting the Label controls I put into the cells off at 14 characters. I’ve tried to fiddle with the ColumnStyles of my table layout panel but none of the options will make the Label control actually ‘fit’ into the cell. I’ve tried all the available column style SizeTypes:

Auto-Size (labels with text values are cropped at 14 characters (“1234567890ABCD”) every time, though columns with no controls present (spacers) are shrunk to nothing)

Percentage (no effect whatsoever – no columns got wider, even when I weighted the column types (value, key, space) to be different sizes).

Absolute (makes the columns x pixels wide, but the labels are STILL cut off at 14 characters – even if the cell is 1,000 pixels wide)

I’ve also tried messing with the Size property of the label, but I can’t edit that because I “Cannot modify the return value of ‘System.Windows.Forms.Control.Size’ because it is not a variable” (whatever that means).

So, having exhausted all those options, how do I make the full label appear in the table cell without being cut off at 14 characters?

Here’s the code that’s generating the table layout panel. It’s using a custom class I built (GridDisplay) that keeps a list of objects (GridDisplayCell) that contain a Control, a row number, a column number, and a few other fields. The class lets me add/remove/move/insert controls to the list and then build the table layout all in one go with the Generate() function (rather than determine it’s size in advance or re-size it as I add items).

       private void FillInCustomerData()
    {
        GridDisplay grid = new GridDisplay(tl_TopLeft);
        int rowMax = 8;
        int columnLabelIndex = 0;

        int curRow = 0;
        int curCol = 0;

        foreach (var item in DD.AllCustomerData["BasicInfo"]) //Dictionary<string, object>
        {
            if (curRow == rowMax)
            {
                curRow = 0;
                curCol = columnLabelIndex + 2; //1 for key column, 1 for value column
            }

            var keyLabel = new Label();
            keyLabel.Text = item.Key;

            var valueLabel = new Label();
            valueLabel.Text = (item.Value == null || item.Value.ToString() == "") ? "NA" :  "1234567890ABDCDEF"; //item.Value.ToString()

            var key = grid.AddItem(new GridDisplayCell(item.Key, keyLabel), item.Key, curRow, curCol);
            // Function Definition: GridDisplay.AddItem(GridDisplayCell(string cellName, Control control), string cellName, int rowNumber, int colNumber)                
            var value = grid.AddItem(new GridDisplayCell(item.Key + "Value", valueLabel), item.Key + "Value", curRow, curCol+1);

            curRow++;
        }

        grid.WrapMode = false;
        grid.AutoSize = true;

        grid.Generate();

        //experimenting with column sizes. NOT WORKING
        foreach (ColumnStyle cs in grid.Table.ColumnStyles)
        {
            cs.SizeType = SizeType.AutoSize;
        }            
    }

And here’s the chunk of my generate function which actually adds the controls to the TableLayoutPanel: (_cells is the list of GridDisplayCells, and AutoSize is a property of GridDisplay in this case (not the TableLayoutPanel’s AutoSize property))

 foreach (var cellItem in _cells)
            {
                if (AutoSize == false && ValidateSize(cellItem.Value.Column, cellItem.Value.Row, false) == false)
                {
                    continue; //the cell was outside the range of the control, so we don't add it.
                }

                _table.Controls.Add(cellItem.Value.CellControl, cellItem.Value.Column, cellItem.Value.Row);
            }

Any help is appreciated.

  • 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-11T20:53:35+00:00Added an answer on June 11, 2026 at 8:53 pm

    Fixed the problem. I needed to set the Label’s AutoSize property to true.

    • 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 want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have an autohotkey script which looks up a word in a bilingual dictionary
This could be a duplicate question, but I have no idea what search terms

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.