Don Philippo
Mitglied
Hallo,
ich hoffe ich hab den Titel des Threads einigermaßen gut rübergebracht?! ;-)
Ich erstelle in meinem Form per "Button-Click" mehrere Textboxes automatisch. Die Anzahl der Textboxen ist abhängig von der Anzahl an zurückgegebenen Daten einer zuvor aufgerufenen Methode ...
Soweit klappt auch alles, also sprich, das dynamische Erstellen der Textboxen.
Jetzt möchte ich jedoch, dass die Textboxen wieder vom Form verschwinden, wenn ich eine neue Berechnung starte und die "neuen" Textboxen erstellt werden oder wenn ich auf den Button "Clear" drücke.
Wie entfernt man dynamisch erstellte Controls?!
Hoffe ich hab's einigermaßen verständlich beschrieben und freue mich auf Eure Hilfe bzw. Ideen!?
Merci mal bis dahin!
ich hoffe ich hab den Titel des Threads einigermaßen gut rübergebracht?! ;-)
Ich erstelle in meinem Form per "Button-Click" mehrere Textboxes automatisch. Die Anzahl der Textboxen ist abhängig von der Anzahl an zurückgegebenen Daten einer zuvor aufgerufenen Methode ...
Soweit klappt auch alles, also sprich, das dynamische Erstellen der Textboxen.
Jetzt möchte ich jedoch, dass die Textboxen wieder vom Form verschwinden, wenn ich eine neue Berechnung starte und die "neuen" Textboxen erstellt werden oder wenn ich auf den Button "Clear" drücke.
Wie entfernt man dynamisch erstellte Controls?!
Hoffe ich hab's einigermaßen verständlich beschrieben und freue mich auf Eure Hilfe bzw. Ideen!?
Merci mal bis dahin!
Code:
/// <summary>
/// Creates Textboxes and shows the decoded values
/// </summary>
/// <param name="x0">x start position for byte matrix</param>
/// <param name="y0">y start position for byte matrix</param>
/// <param name="b">width of byte textbox</param>
/// <param name="h">height of byte text box</param>
/// <param name="iNoOfBoxes">number of byte textboxes have to be shown</param>
/// <param name="sDataArray">data array includes the filtered string bytes</param>
private void CreateTextboxes(int x0, int y0, int b, int h, int iNoOfBoxes, string[,] sDataArray)
{
int iWindowLength = 0;
int iArrIdx = 3;
if (tbCode.Text != "")
{
int count = 0;
int iDist = 0;
int zmax = 3;
for (int z = 0; z < zmax; z++)
{
for (int s = 0; s < iNoOfBoxes; s++)
{
TextBox tb = new TextBox();
if (z > 0)
{
tb.Bounds = new Rectangle(new Point(x0 + (s * b) + iDist, y0 + (z * (h + K_DIST))), new Size(b, h));
}
else
{
tb.Bounds = new Rectangle(new Point(x0 + (s * b) + iDist, y0 + (z * h)), new Size(b, h));
}
tb.BorderStyle = BorderStyle.Fixed3D;
count += 1;
iDist += K_DIST;
iWindowLength = x0 + (s * b) + iDist + 2;
tb.Name = "tb" + count.ToString();
// Text fuellen
tb.Text = sDataArray[z, iArrIdx + s];
tb.TextAlign = HorizontalAlignment.Center;
tb.Font = new System.Drawing.Font("Courier New", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
tb.Anchor = AnchorStyles.Left | AnchorStyles.Top;
this.Controls.Add(tb);
if (s >= iNoOfBoxes - 1)
{
count = 0;
iDist = 0;
}
}
}
}
}