Dimensionnement TableLayoutPanel

Je ne peut pas utiliser le droit de contrôle de ce que je veux. Je suis pour le remplissage d'un tableau avec les contrôles et je veux que chaque colonne de taille automatiquement pour les commandes contenues à l'intérieur d'elle. Par exemple, une colonne de zones de texte sera plus large qu'une colonne de cases à cocher. Je ne veux pas jouer avec mesure si je peux l'aider, en raison de la complexité des différents systèmes d'exploitation, les différents DPI, les différentes polices de caractères, etc. La table peut étendre horizontalement pour ajuster les contrôles, avec une barre de défilement. Comment est-ce possible avec un TableLayoutPanel - ou un autre contrôle?

Grâce.

Édité pour ajouter le code:

    private void UpdateLocations()
{
tableLayoutPanel1.RowCount = CurrentSchedule.location.Length + 1;
tableLayoutPanel1.ColumnCount = 7;
int row = 1;
int timeWidth = TextRenderer.MeasureText("00:00:00x", tableLayoutPanel1.Font).Width;
Label lab = new Label();
lab.Text = "Location";
tableLayoutPanel1.Controls.Add(lab, 0, 0);
lab = new Label();
lab.Text = "Arrive";
tableLayoutPanel1.Controls.Add(lab, 1, 0);
lab = new Label();
lab.Text = "Depart";
tableLayoutPanel1.Controls.Add(lab, 2, 0);
lab = new Label();
lab.Text = "Pass?";
tableLayoutPanel1.Controls.Add(lab, 3, 0);
lab = new Label();
lab.Text = "Path";
tableLayoutPanel1.Controls.Add(lab, 4, 0);
lab = new Label();
lab.Text = "Plat";
tableLayoutPanel1.Controls.Add(lab, 5, 0);
lab = new Label();
lab.Text = "Line";
tableLayoutPanel1.Controls.Add(lab, 6, 0);
foreach (location loc in CurrentSchedule.location)
{
TextBox tb = new TextBox();
tb.Text = loc.locationID;
tableLayoutPanel1.Controls.Add(tb, 0, row);
tb = new TextBox();
tb.Text = loc.arrivalTime;
tb.Width = timeWidth;
tableLayoutPanel1.Controls.Add(tb, 1, row);
tb = new TextBox();
tb.Text = loc.departureTime;
tb.Width = timeWidth;
tableLayoutPanel1.Controls.Add(tb, 2, row);
CheckBox cb = new CheckBox();
cb.Checked = loc.passingTime;
tableLayoutPanel1.Controls.Add(cb, 3, row);
tb = new TextBox();
tb.Text = loc.pathCode;
tableLayoutPanel1.Controls.Add(tb, 4, row);
tb = new TextBox();
tb.Text = loc.platformCode;
tableLayoutPanel1.Controls.Add(tb, 5, row);
tb = new TextBox();
tb.Text = loc.lineCode;
tableLayoutPanel1.Controls.Add(tb, 6, row);
row++;
}
/*for (int idx = 0; idx < tableLayoutPanel1.RowCount; idx++)
{
tableLayoutPanel1.RowStyles[idx].SizeType = SizeType.AutoSize;
}
for (int idx = 0; idx < tableLayoutPanel1.ColumnCount; idx++)
{
tableLayoutPanel1.ColumnStyles[idx].SizeType = SizeType.AutoSize;
}*/
}

(Oui, il doit lourd refactoring - je suis juste essayer de l'obtenir pour travailler d'abord)

Le commentaire sur les bits de cause en dehors des limites des exceptions, même si logiquement (pour moi), il ne devrait pas. La gamme semble limité à ce que j'ai défini au moment de la conception, et non pas au moment de l'exécution.

source d'informationauteur GeoffM