Verändern der Größe von Zeilen und Spalten in einer TableLayoutPanel, wenn in der Größe verändert

Entwickle ich eine einfache app, die verwendet wird, zu emulieren eine serielle Tastatur. Die app benötigt ein in der Größe veränderbares Fenster, mit der "keys" (Tasten in diesem Fall) Strecke mit dem Fenster. Ich habe mich entschieden, es angedockt TableLayoutPanel und legen Sie die Spalten und Zeilen und Größe mit einem Prozentsatz.

Sagen, ich habe eine 7 x 3-raster von virtuellen Tasten auf meiner Tastatur wie folgt:

+--+--+--+--+--+--+--+
|  |  |  |  |  |  |  |
+--+--+--+--+--+--+--+
|  |  |  |  |  |  |  |
+--+--+--+--+--+--+--+
|  |  |  |  |  |  |  |
+--+--+--+--+--+--+--+

Wenn ich die Größe meiner form der letzten Zeile und Spalte nehmen die Flaute, wenn der Raum nicht gleichermaßen geteilt werden.

Da werde ich dock einen button in jeder Zelle, es sieht seltsam aus, wenn die Letzte Zeile/Spalte mit buttons größer ist.

Habe ich behoben, indem man einfach eine zusätzliche Zeile und Spalte, nicht über irgendwelche Tasten, aber das sieht hässlich, wenn alle slack space ist auf der rechten Seite und der Unterseite, was ich wirklich will, ist eine im wesentlichen Mitte der Tastatur.

Ich habe versucht, erstellen Sie eine 9 x 5-Gitters und die Einstellung der ersten und letzten Spalte und Zeile automatisch, aber ich kann nicht scheinen, zu tun, was ich erreichen will.

Muss es eine Möglichkeit geben, dies zu tun?

Bearbeiten: Hier ist meine designer-code. Ich bin eigentlich emuliert eine Tastatur mit 19 x 10-raster.

this.tlpKeyboard1.ColumnCount = 20;
this.tlpKeyboard1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5F));
this.tlpKeyboard1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5F));
this.tlpKeyboard1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5F));
this.tlpKeyboard1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5F));
this.tlpKeyboard1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5F));
this.tlpKeyboard1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5F));
this.tlpKeyboard1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5F));
this.tlpKeyboard1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5F));
this.tlpKeyboard1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5F));
this.tlpKeyboard1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5F));
this.tlpKeyboard1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5F));
this.tlpKeyboard1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5F));
this.tlpKeyboard1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5F));
this.tlpKeyboard1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5F));
this.tlpKeyboard1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5F));
this.tlpKeyboard1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5F));
this.tlpKeyboard1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5F));
this.tlpKeyboard1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5F));
this.tlpKeyboard1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5F));
this.tlpKeyboard1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5F));
this.tlpKeyboard1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tlpKeyboard1.Location = new System.Drawing.Point(3, 3);
this.tlpKeyboard1.Name = "tlpKeyboard1";
this.tlpKeyboard1.RowCount = 11;
this.tlpKeyboard1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 9.090908F));
this.tlpKeyboard1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 9.090908F));
this.tlpKeyboard1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 9.090908F));
this.tlpKeyboard1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 9.090908F));
this.tlpKeyboard1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 9.090908F));
this.tlpKeyboard1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 9.090908F));
this.tlpKeyboard1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 9.090908F));
this.tlpKeyboard1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 9.090908F));
this.tlpKeyboard1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 9.090908F));
this.tlpKeyboard1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 9.090908F));
this.tlpKeyboard1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 9.090908F));
this.tlpKeyboard1.Size = new System.Drawing.Size(977, 528);
  • Klingt wie die Spalten arent setup werden Prozentsätze. Kannst du deinen code hast du bisher?
InformationsquelleAutor Bryan | 2011-02-17
Schreibe einen Kommentar