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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:50:58+00:00 2026-05-16T07:50:58+00:00

I have a class which derived from the TableLayoutPanel. This class makeup the tabel

  • 0

I have a class which derived from the TableLayoutPanel. This class makeup the tabel corrects (grid 3×8) and add some checkboxes in some cells. All this is done by overriding the function InitLayout().

public class TableLayoutPanelHours : TableLayoutPanel
{
    protected override void InitLayout()
    {  
        RowCount = 3;
        ColumnCount = 8;

        // Set some column and row styles
        RowStyles[0].SizeType = SizeType.Percent;
        RowStyles[0].Height = (100 / RowCount);
        // ... etc ...

        // ... create checkbox with the name checkbox1
        Controls.Add(checkbox1, 1, 1);  // Put in cell 1x1
        // ... etc ...
    }
}

After building, the Control is available from the Toolbox of VS2010.

Then, putting the control on a simple Windows Form, some things are happen that I don’t userstand:
– the control is not makeup yet during design mode. The TableLayoutPanel is displaying the default 2×2 grid and checkboxes are on a strange place. After runtime, the control is displaying correctly (3×8 grid with Checkbox on the correctly places)
– And: in the InitializeComponent() of the Form, I see these lines appears:

// 
// tableLayoutPanelHours1
// 
this.tableLayoutPanelHours1.ColumnCount = 8;
this.tableLayoutPanelHours1.ColumnCount = 3; 
this.tableLayoutPanelHours1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); 
// ....

I have excepted that these lines are not visible in the InitializeComponent() of the Windows Forms, but why is this happen?

Thanks.

  • 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-05-16T07:50:58+00:00Added an answer on May 16, 2026 at 7:50 am

    You are doing battle with the designer for TLP. It is a custom one, as you can clearly see by the way it behaves in design mode. Using the InitLayout() method to initialize the TLP is not correct, it’s too late. You should do it in the constructor instead.

    But that still won’t get you what you want, the TLP designer hard-codes the number of rows and columns when it initializes to 2×2. And it can’t handle code changing it at design time (like you did in InitLayout), there are no events to listen to. You will have to give up on that designer.

    Should be okay since you already initialize the TLP the way you want it. Use the [Designer] attribute to fall back to ControlDesigner. If that’s hardship for your control then you will have to create your own designer. Use Reflector to look at the internal TableLayoutPanelDesigner class to get a start on that. Beware that it isn’t a simple designer.

    You see those property assignments in InitializeComponent because the [DefaultValue] attribute on those properties declares a different default. You can fix that by adding a private ShouldSerializeRowCount (and ColumnCount) method to your class. Return false to prevent the property from being serialized.

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

Sidebar

Related Questions

I have a class which is derived from a base class, and have many
I have a class, say DerivedBindingList<T> , which is derived from BindingList<T> . I
I have a class derived from CTreeCtrl. In some circumstances the user might be
I have a class derived from QGraphicsView , which contains QGraphicsItem -derived elements. I
I want to build a jar containing a class which I have derived from
I have a class derived from TreeviewItem(Custom TreeViewItem) which is used by a class
I have a class derived from base class which has a private field. How
I have DataAccess class which is derived from DataAccessor. DataAccessor class is the DB
If i have a class which accepts a generic type derived from IUser, how
I have a base class which has two child classes derived from it. class

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.