none
VS2013 Button auf Automatisch erstellten Taps anlegen RRS feed

  • Frage

  • Hallo,

    Ich versuche gerade verzweifelt Button auf Automatisch erstellten Tabs zusetzen

    anbei mal der Code

    for (x = 1; x <= Kartenzahl_int; x++) { string title = "Relais " + (tabRelais.TabCount + 1).ToString(); TabPage myTabPage = new TabPage(title); tabRelais.TabPages.Add(myTabPage); }

    Ich kann halt erst jetzt den Namen wählen wo er hinsoll also ich hab ja keinen festen.

    Irgendwie stehe ich auf den schlauch

    Ich hoffe es kann mir jemand helfen das Problem zu lösen.

    Gruß Daniel

    Donnerstag, 5. März 2015 15:43

Antworten

  • Für alle die es Interessiert ich hab jetzt eine Lösung gefunden.

     for (x = 1; x <= Kartenzahl_int; x++)                                              {
                        string title = "Relais " + (tabRelais.TabCount + 1).ToString();
                        TabPage myTabPage = new TabPage(title);
                        tabRelais.TabPages.Add(myTabPage);
                        
                        Button[] Buttons = new Button[9];
                        PictureBox[] Bildchen = new PictureBox[9];
                        CheckBox[] Checkboxs = new CheckBox[9];
                        r = 0;
                        for( y=1; y<=4;y++)
                        {
                            Bildchen[y] = new PictureBox();
                            Bildchen[y].Text = "Bild " + (y);
                            Bildchen[y].Size = new System.Drawing.Size(100,100);
                            Bildchen[y].Location = new Point(5, r + 40);
                            Bildchen[y].Image = new Bitmap("product_default_0.bmp");
                            myTabPage.Controls.Add(Bildchen[y]);
    
                            Checkboxs[y] = new CheckBox();
                            Checkboxs[y].Text = "Senden" + (y);
                            Checkboxs[y].Location = new Point(110, r + 70);
                            myTabPage.Controls.Add(Checkboxs[y]);
    
                            Buttons[y] = new Button();
                            Buttons[y].Text = "Relais " + (y);
                            Buttons[y].Location = new Point(110, r + 45);
                            myTabPage.Controls.Add(Buttons[y]);
                            r += 130;
                        }
                        r = 0;
                        for (z = 5; z <= 8; z++)
                        {
                            Bildchen[z] = new PictureBox();
                            Bildchen[z].Text = "Bild " + (z);
                            Bildchen[z].Size = new System.Drawing.Size(100, 100);
                            Bildchen[z].Location = new Point(300, r + 40);
                            Bildchen[z].Image = new Bitmap("product_default_0.bmp");
                            myTabPage.Controls.Add(Bildchen[z]);
    
                            Checkboxs[z] = new CheckBox();
                            Checkboxs[z].Text = "Senden" + (z);
                            Checkboxs[z].Location = new Point(410, r + 70);
                            myTabPage.Controls.Add(Checkboxs[z]);
    
                            Buttons[z] = new Button();
                            Buttons[z].Text = "Relais " + (z);
                            Buttons[z].Location = new Point(410, r + 45);
                            myTabPage.Controls.Add(Buttons[z]);
                            r += 130;
                        }
    
                    }

    Viel spaß damit :-)

    • Als Antwort markiert Danielk112 Samstag, 7. März 2015 07:39
    Samstag, 7. März 2015 07:38