Autor Beitrag
DarkSu
Hält's aus hier
Beiträge: 14



BeitragVerfasst: Di 02.04.13 14:08 
Hallo zusammen ..

Ich habe hier wieder mal ein Problem zu dem ich vielleicht eurer Hilfe brauche. Ich verwende in meinem WinForm ein TabControl mit 11 tabPages .. In einer tabPage die immer offen ist sind die Settings.
Die heißt auf dieser tabPage sind Checkboxen mit deren Hilfe ich tabPages anzeigen und verbergen will. Geht soweit auf wenn man bestimmte Regeln beachtet. Aber die beachtet man nun mal nicht .. HI ..
Die Checkboxen frage ich über einen timer1 ab. Wie das aussieht möchte ich anhand einer Codes zeigen ..

ausblenden volle Höhe C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
        private void timer1_Tick(object sender, EventArgs e)
        {
            // tabPage1 Hide and Show
            if (checkBox2.Checked)
            {
                if (!tabControl1.TabPages.Contains(tabPage1))
                    tabControl1.TabPages.Insert(0, tabPage1);
            }
            else
            {
                tabControl1.TabPages.Remove(tabPage1);
            }

            // tabPage2 Hide and Show
            if (checkBox3.Checked)
            {
                if (!tabControl1.TabPages.Contains(tabPage2))
                    tabControl1.TabPages.Insert(1, tabPage2);
            }
            else
            {
                tabControl1.TabPages.Remove(tabPage2);
            }

            // tabPage3 Hide and Show
            if (checkBox4.Checked)
            {
                if (!tabControl1.TabPages.Contains(tabPage3))
                    tabControl1.TabPages.Insert(2,tabPage3);
            }
            else
            {
                tabControl1.TabPages.Remove(tabPage3);
            }

            // tabPage4 Hide and Show
            if (checkBox5.Checked)
            {
                if (!tabControl1.TabPages.Contains(tabPage4))
                    tabControl1.TabPages.Insert(3,tabPage4);
            }
            else
            {
                tabControl1.TabPages.Remove(tabPage4);
            }

            // tabPage5 Hide and Show
            if (checkBox6.Checked)
            {
                if (!tabControl1.TabPages.Contains(tabPage5))
                    tabControl1.TabPages.Insert(4,tabPage5);
            }
            else
            {
                tabControl1.TabPages.Remove(tabPage5);
            }

            // tabPage6 Hide and Show
            if (checkBox7.Checked)
            {
                if (!tabControl1.TabPages.Contains(tabPage6))
                    tabControl1.TabPages.Insert(5,tabPage6);
            }
            else
            {
                tabControl1.TabPages.Remove(tabPage6);
            }

            // tabPage7 Hide and Show
            if (checkBox8.Checked)
            {
                if (!tabControl1.TabPages.Contains(tabPage7))
                    tabControl1.TabPages.Insert(6,tabPage7);
            }
            else
            {
                tabControl1.TabPages.Remove(tabPage7);
            }

            // tabPage8 Hide and Show
            if (checkBox9.Checked)
            {
                if (!tabControl1.TabPages.Contains(tabPage8))
                    tabControl1.TabPages.Insert(7,tabPage8);
            }
            else
            {
                tabControl1.TabPages.Remove(tabPage8);
            }

            // tabPage9 Hide and Show
            if (checkBox10.Checked)
            {
                if (!tabControl1.TabPages.Contains(tabPage9))
                    tabControl1.TabPages.Insert(8, tabPage9);
            }
            else
            {
                tabControl1.TabPages.Remove(tabPage9);
            }
            
            // tabPage10 Hide and Show
            if (checkBox11.Checked)
            {
                if (!tabControl1.TabPages.Contains(tabPage10))
                    tabControl1.TabPages.Insert(8, tabPage10);
            }
            else
            {
                tabControl1.TabPages.Remove(tabPage10);
            }

        }


Im Designer sollten alle tabpages richtig konfiguriert sein. Siehe Code:

ausblenden volle Höhe C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
        // 
            // tabPage1
            // 
            this.tabPage1.Controls.Add(this.webBrowser1);
            this.tabPage1.Location = new System.Drawing.Point(422);
            this.tabPage1.Name = "tabPage1";
            this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
            this.tabPage1.Size = new System.Drawing.Size(790627);
            this.tabPage1.TabIndex = 0;
            this.tabPage1.Text = "50/70 MHz";
            this.tabPage1.UseVisualStyleBackColor = true;
            // 
            // tabPage2
            // 
            this.tabPage2.Controls.Add(this.webBrowser2);
            this.tabPage2.Location = new System.Drawing.Point(422);
            this.tabPage2.Name = "tabPage2";
            this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
            this.tabPage2.Size = new System.Drawing.Size(790627);
            this.tabPage2.TabIndex = 1;
            this.tabPage2.Text = "50 MHz Region 2";
            this.tabPage2.UseVisualStyleBackColor = true;
            // 
            // tabPage3
            // 
            this.tabPage3.Controls.Add(this.webBrowser3);
            this.tabPage3.Location = new System.Drawing.Point(422);
            this.tabPage3.Name = "tabPage3";
            this.tabPage3.Padding = new System.Windows.Forms.Padding(3);
            this.tabPage3.Size = new System.Drawing.Size(790627);
            this.tabPage3.TabIndex = 2;
            this.tabPage3.Text = "50 MHz Region 3";
            this.tabPage3.UseVisualStyleBackColor = true;
            // 
            // tabPage4
            // 
            this.tabPage4.Controls.Add(this.webBrowser4);
            this.tabPage4.Location = new System.Drawing.Point(422);
            this.tabPage4.Name = "tabPage4";
            this.tabPage4.Padding = new System.Windows.Forms.Padding(3);
            this.tabPage4.Size = new System.Drawing.Size(790627);
            this.tabPage4.TabIndex = 3;
            this.tabPage4.Text = "144/432 MHz";
            this.tabPage4.UseVisualStyleBackColor = true;
            // 
            // tabPage5
            // 
            this.tabPage5.Controls.Add(this.webBrowser5);
            this.tabPage5.Location = new System.Drawing.Point(422);
            this.tabPage5.Name = "tabPage5";
            this.tabPage5.Size = new System.Drawing.Size(790627);
            this.tabPage5.TabIndex = 4;
            this.tabPage5.Text = "144/432 MHz Region 2";
            this.tabPage5.UseVisualStyleBackColor = true;
            // 
            // tabPage6
            // 
            this.tabPage6.Controls.Add(this.webBrowser6);
            this.tabPage6.Location = new System.Drawing.Point(422);
            this.tabPage6.Name = "tabPage6";
            this.tabPage6.Size = new System.Drawing.Size(790627);
            this.tabPage6.TabIndex = 5;
            this.tabPage6.Text = "144/432 MHz Region 3";
            this.tabPage6.UseVisualStyleBackColor = true;
            // 
            // tabPage7
            // 
            this.tabPage7.Controls.Add(this.webBrowser7);
            this.tabPage7.Location = new System.Drawing.Point(422);
            this.tabPage7.Name = "tabPage7";
            this.tabPage7.Size = new System.Drawing.Size(790627);
            this.tabPage7.TabIndex = 6;
            this.tabPage7.Text = "Microwave";
            this.tabPage7.UseVisualStyleBackColor = true;
            // 
            // tabPage8
            // 
            this.tabPage8.Controls.Add(this.webBrowser8);
            this.tabPage8.Location = new System.Drawing.Point(422);
            this.tabPage8.Name = "tabPage8";
            this.tabPage8.Padding = new System.Windows.Forms.Padding(3);
            this.tabPage8.Size = new System.Drawing.Size(790627);
            this.tabPage8.TabIndex = 7;
            this.tabPage8.Text = "160/80M Lowband";
            this.tabPage8.UseVisualStyleBackColor = true;
            // 
            // tabPage9
            // 
            this.tabPage9.Controls.Add(this.webBrowser9);
            this.tabPage9.Location = new System.Drawing.Point(422);
            this.tabPage9.Name = "tabPage9";
            this.tabPage9.Size = new System.Drawing.Size(790627);
            this.tabPage9.TabIndex = 8;
            this.tabPage9.Text = "EME/JT65/CW";
            this.tabPage9.UseVisualStyleBackColor = true;
            // 
            // tabPage10
            // 
            this.tabPage10.Controls.Add(this.webBrowser10);
            this.tabPage10.Location = new System.Drawing.Point(422);
            this.tabPage10.Name = "tabPage10";
            this.tabPage10.Size = new System.Drawing.Size(790627);
            this.tabPage10.TabIndex = 9;
            this.tabPage10.Text = "GDXF";
            this.tabPage10.UseVisualStyleBackColor = true;
            // 
            // tabPage11
            // 
            this.tabPage11.Controls.Add(this.groupBox3);
            this.tabPage11.Controls.Add(this.groupBox2);
            this.tabPage11.Controls.Add(this.groupBox1);
            this.tabPage11.Location = new System.Drawing.Point(422);
            this.tabPage11.Name = "tabPage11";
            this.tabPage11.Size = new System.Drawing.Size(790627);
            this.tabPage11.TabIndex = 10;
            this.tabPage11.Text = "Settings";
            this.tabPage11.UseVisualStyleBackColor = true;


Also gehen wir mal ein Beispiel durch .. Alle tabpages sind beim Start AUS und nun schalte ich alle ein .. Reihenfolge beim Einschalten 1-10 .. und dann wieder umgekehrt aus. So geht es alles korrekt .. Weil vermutlich alle Indexes stimmen.

Nun die Dunkle Seite der Macht .. hi .. Ich starte wieder mit allen Tabs AUS und klicke auf checkBox2 und öffne tabPage1 . Alles bestens und die Page kommt auch an 1. Stellte im Control. Klicke ich auf die checkBox3 ohne das eine andere Aktiv ist erscheint der schon mal Falsch, nämlich hinter den Settings .. Sollte ja vorne stehen. Schalte ich zuerst tabpage1 ein und dann die tabpage2 dann kommt sie an der Richtigen stelle. (tab1,tab2,Settings) ..

Um es nun kurz zu machen Produziere ich einfach mal einen Fehler . tab1 ein .. tab2 ein .. und versuche nun tab7 einzuschalten. Jetzt kommt ein Fehler: InvalidArgument=Value mit dem Wert 6 ist für index ungültig.

Dieser Fehler ist nicht Fix .. Denn bekomm ich auf 4 auf 5 oder wo auch immer bzw. wie auch immer ich hin und her klicke. An was wird das wohl liegen ? Kann mir da vielleicht jemand helfen bzw. einen Tipp geben. Danke !

Gruß DarkSu
DarkSu Threadstarter
Hält's aus hier
Beiträge: 14



BeitragVerfasst: Di 02.04.13 16:37 
Hallo Gemeinde ..

Also als Quick and Dirty Lösung schicke ich die einzelnen tabPages beim wieder einfügen einfach alle nach Index 0 .. So werden sie zumindest vor den Settings eingefügt. Sollte jemanden was dazu einfallen, dann bitte nicht zögern zu Antworten. Würde mich freuen ..


cu DarkSu