TableLayoutPanel
-
Hi,
ich muss ein TableLayoutPanel dynamisch erstellen.
Ich hab mich da mal durch die MSDN-Hilfe gelesen und was entdeckt was aber nicht so recht funktionieren will.
"The TableLayoutPanel control can expand to accommodate new controls when they are added, depending on the value of the RowCount, ColumnCount, and GrowStyle properties. Setting either the RowCount or ColumnCount property to a value of 0 specifies that the TableLayoutPanel will be unbound in the corresponding direction."
siehe TableLayoutPanel ClassSo, mein Problem ist jetz: Ich kann die Werte bei ColumnCount bzw bei RowCount nicht auf 0 setzen. Da meckert VS rum, dass der Wert größer als Null sein muss.
Also hä???
Ich checks nicht.
-
Leg doch mal eines per Designer an und schau Dir mal im InitComponent an, wie das per Code gemacht wird. Letzendlich wird ja jede Aktion mit dem Designer in Code umgesetzt. Das kann Dir vllt. weiterhelfen.
-
doch wo finde ich den TableLayoutPanel im Designer?
-
Alle Windows Forms
Wenns da nicht auftaucht über Element hinzufügen einbinden.
-
mein problem ist nun folgendes:
ich hab z.b. 14 datensätze.
d.h ich muss in meinem panel dann 14 zusätzliche zeilen hinzufügen.
und den code im designer kann ich ja nicht ändern.
also muss ich das irgendwo in meinem programm machen.
Nur wie?
bis jetz siehts halt so aus.public partial class Form1 : Form { TableLayoutPanelGrowStyle tblGrowStyle; public Form1() { InitializeComponent(); tblGrowStyle = this.tableLayoutPanel1.GrowStyle; } private void b_datei_einlesen_Click(object sender, EventArgs e) { openFileDialog1.ShowDialog(); } private void openFileDialog1_FileOk(object sender, CancelEventArgs e) { this.Activate(); string Filename = openFileDialog1.FileName; datei_auswerten(Filename); } private void datei_auswerten(string dateipfad) { FileInfo theSourceFile = new FileInfo(dateipfad); StreamReader reader = theSourceFile.OpenText(); string strline; int anzahl = 0; while ((strline = reader.ReadLine()) != null) { if (strline.Contains(@"projekt value")) { anzahl++; } } formaufbau(anzahl); } private void formaufbau(int zahl) { for (int i = 0; i < zahl; i++) tblGrowStyle = TableLayoutPanelGrowStyle.AddRows; } }