Registerkarten
-
Moin!
Ich wage mich mal wieder an grafische Ressourcen heran. Ich möchte ein Dialogfeld mit verschiedenen Registerkarten erstellen. Das hat soweit schon geklappt: Es gibt defaultmäßig 5 Reiter (Tab 1-5).
1. Wie kann ich die Reiternamen ändern??
2. Wie kann ich auf die anderen, nicht aufgeschlagenen, Registerkarten im Dialogeditor wechseln, wenn ich sie noch mit Inhalt füllen will?Schöne Grüße!
-
Ich habe einmal ein Bsp geschrieben
mit Registerkarten und einigen Extras,
wie Textbox, Zwischenablage, ...using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; namespace Ü1 { /// <summary> /// Zusammendfassende Beschreibung für Form1. /// </summary> public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.TabControl tabControl1; private System.Windows.Forms.TabPage tabPage1; private System.Windows.Forms.TabPage tabPage2; private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button3; private System.Windows.Forms.Button button4; private System.Windows.Forms.Button button5; private System.Windows.Forms.Button button6; private System.Windows.Forms.ListBox listBox1; private System.Windows.Forms.Button button7; private System.Windows.Forms.Button button8; private System.Windows.Forms.Button button9; private System.Windows.Forms.Button button12; private System.Windows.Forms.TextBox textBox2; private System.Windows.Forms.Button button10; private System.Windows.Forms.TabPage tabPage3; private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.RadioButton radioButton1; private System.Windows.Forms.RadioButton radioButton2; private System.Windows.Forms.RadioButton radioButton3; private System.Windows.Forms.RadioButton radioButton4; private System.Windows.Forms.Button button11; private System.Windows.Forms.Button button13; private System.Windows.Forms.CheckBox checkBox1; private System.Windows.Forms.CheckBox checkBox2; private System.Windows.Forms.CheckBox checkBox3; private System.Windows.Forms.Button button14; private System.Windows.Forms.Button button15; private System.Windows.Forms.CheckBox checkBox4; /// <summary> /// Erforderliche Designervariable. /// </summary> private System.ComponentModel.Container components = null; public Form1() { // // Erforderlich für die Windows Form-Designerunterstützung // InitializeComponent(); // // TODO: Fügen Sie den Konstruktorcode nach dem Aufruf von InitializeComponent hinzu // } /// <summary> /// Die verwendeten Ressourcen bereinigen. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// <summary> /// Erforderliche Methode für die Designerunterstützung. /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden. /// </summary> private void InitializeComponent() { this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabPage1 = new System.Windows.Forms.TabPage(); this.tabPage2 = new System.Windows.Forms.TabPage(); this.textBox1 = new System.Windows.Forms.TextBox(); this.button1 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button(); this.button4 = new System.Windows.Forms.Button(); this.button5 = new System.Windows.Forms.Button(); this.button6 = new System.Windows.Forms.Button(); this.listBox1 = new System.Windows.Forms.ListBox(); this.button7 = new System.Windows.Forms.Button(); this.button8 = new System.Windows.Forms.Button(); this.button9 = new System.Windows.Forms.Button(); this.button12 = new System.Windows.Forms.Button(); this.textBox2 = new System.Windows.Forms.TextBox(); this.button10 = new System.Windows.Forms.Button(); this.tabPage3 = new System.Windows.Forms.TabPage(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.radioButton1 = new System.Windows.Forms.RadioButton(); this.radioButton2 = new System.Windows.Forms.RadioButton(); this.radioButton3 = new System.Windows.Forms.RadioButton(); this.radioButton4 = new System.Windows.Forms.RadioButton(); this.button11 = new System.Windows.Forms.Button(); this.button13 = new System.Windows.Forms.Button(); this.checkBox1 = new System.Windows.Forms.CheckBox(); this.checkBox2 = new System.Windows.Forms.CheckBox(); this.checkBox3 = new System.Windows.Forms.CheckBox(); this.button14 = new System.Windows.Forms.Button(); this.button15 = new System.Windows.Forms.Button(); this.checkBox4 = new System.Windows.Forms.CheckBox(); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); this.tabPage2.SuspendLayout(); this.tabPage3.SuspendLayout(); this.groupBox1.SuspendLayout(); this.SuspendLayout(); // // tabControl1 // this.tabControl1.Controls.AddRange(new System.Windows.Forms.Control[] { this.tabPage1, this.tabPage2, this.tabPage3}); this.tabControl1.Location = new System.Drawing.Point(4, 4); this.tabControl1.Name = "tabControl1"; this.tabControl1.SelectedIndex = 0; this.tabControl1.Size = new System.Drawing.Size(420, 228); this.tabControl1.TabIndex = 1; // // tabPage1 // this.tabPage1.Controls.AddRange(new System.Windows.Forms.Control[] { this.button6, this.button5, this.button4, this.button3, this.button2, this.button1, this.textBox1}); this.tabPage1.Location = new System.Drawing.Point(4, 22); this.tabPage1.Name = "tabPage1"; this.tabPage1.Size = new System.Drawing.Size(412, 202); this.tabPage1.TabIndex = 0; this.tabPage1.Text = "Textbox"; // // tabPage2 // this.tabPage2.Controls.AddRange(new System.Windows.Forms.Control[] { this.button10, this.textBox2, this.button12, this.button9, this.button8, this.button7, this.listBox1}); this.tabPage2.Location = new System.Drawing.Point(4, 22); this.tabPage2.Name = "tabPage2"; this.tabPage2.Size = new System.Drawing.Size(412, 202); this.tabPage2.TabIndex = 1; this.tabPage2.Text = "Listbox"; // // textBox1 // this.textBox1.Location = new System.Drawing.Point(16, 8); this.textBox1.Multiline = true; this.textBox1.Name = "textBox1"; this.textBox1.Size = new System.Drawing.Size(384, 64); this.textBox1.TabIndex = 0; this.textBox1.Text = "textBox1"; // // button1 // this.button1.Location = new System.Drawing.Point(80, 80); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(128, 24); this.button1.TabIndex = 1; this.button1.Text = "Text zuweisen"; this.button1.Click += new System.EventHandler(this.button1_Click); // // button2 // this.button2.Location = new System.Drawing.Point(208, 80); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(128, 24); this.button2.TabIndex = 2; this.button2.Text = "Text löschen"; this.button2.Click += new System.EventHandler(this.button2_Click); // // button3 // this.button3.Location = new System.Drawing.Point(80, 128); this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(256, 24); this.button3.TabIndex = 3; this.button3.Text = "Text in Zwischenablage kopieren"; this.button3.Click += new System.EventHandler(this.button3_Click); // // button4 // this.button4.Location = new System.Drawing.Point(80, 152); this.button4.Name = "button4"; this.button4.Size = new System.Drawing.Size(256, 24); this.button4.TabIndex = 4; this.button4.Text = "Text aus Zwischenablage kopieren"; this.button4.Click += new System.EventHandler(this.button4_Click); // // button5 // this.button5.Location = new System.Drawing.Point(80, 104); this.button5.Name = "button5"; this.button5.Size = new System.Drawing.Size(256, 24); this.button5.TabIndex = 5; this.button5.Text = "Text markieren"; this.button5.Click += new System.EventHandler(this.button5_Click); // // button6 // this.button6.Location = new System.Drawing.Point(80, 176); this.button6.Name = "button6"; this.button6.Size = new System.Drawing.Size(256, 23); this.button6.TabIndex = 6; this.button6.Text = "Anzeigen erste Zeile"; this.button6.Click += new System.EventHandler(this.button6_Click); // // listBox1 // this.listBox1.Location = new System.Drawing.Point(8, 8); this.listBox1.Name = "listBox1"; this.listBox1.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended; this.listBox1.Size = new System.Drawing.Size(184, 173); this.listBox1.TabIndex = 0; // // button7 // this.button7.Location = new System.Drawing.Point(200, 32); this.button7.Name = "button7"; this.button7.Size = new System.Drawing.Size(200, 23); this.button7.TabIndex = 1; this.button7.Text = "Zehn Einträge hinzufügen"; this.button7.Click += new System.EventHandler(this.button7_Click); // // button8 // this.button8.Location = new System.Drawing.Point(200, 8); this.button8.Name = "button8"; this.button8.Size = new System.Drawing.Size(200, 23); this.button8.TabIndex = 2; this.button8.Text = "Löschen"; this.button8.Click += new System.EventHandler(this.button8_Click); // // button9 // this.button9.Location = new System.Drawing.Point(200, 80); this.button9.Name = "button9"; this.button9.Size = new System.Drawing.Size(96, 23); this.button9.TabIndex = 3; this.button9.Text = "Eintrag einfügen"; this.button9.Click += new System.EventHandler(this.button9_Click); // // button12 // this.button12.Location = new System.Drawing.Point(200, 56); this.button12.Name = "button12"; this.button12.Size = new System.Drawing.Size(200, 23); this.button12.TabIndex = 6; this.button12.Text = "Markierten Eintrag löschen"; this.button12.Click += new System.EventHandler(this.button12_Click); // // textBox2 // this.textBox2.Location = new System.Drawing.Point(298, 81); this.textBox2.Name = "textBox2"; this.textBox2.TabIndex = 7; this.textBox2.Text = "Neuer Eintrag"; // // button10 // this.button10.Location = new System.Drawing.Point(200, 104); this.button10.Name = "button10"; this.button10.Size = new System.Drawing.Size(200, 23); this.button10.TabIndex = 8; this.button10.Text = "Alle Einträge markieren"; this.button10.Click += new System.EventHandler(this.button10_Click); // // tabPage3 // this.tabPage3.Controls.AddRange(new System.Windows.Forms.Control[] { this.checkBox4, this.button14, this.button15, this.checkBox3, this.checkBox2, this.checkBox1, this.button13, this.button11, this.groupBox1}); this.tabPage3.Location = new System.Drawing.Point(4, 22); this.tabPage3.Name = "tabPage3"; this.tabPage3.Size = new System.Drawing.Size(412, 202); this.tabPage3.TabIndex = 2; this.tabPage3.Text = "RadioButtons"; // // groupBox1 // this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] { this.radioButton4, this.radioButton3, this.radioButton2, this.radioButton1}); this.groupBox1.Location = new System.Drawing.Point(8, 8); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(128, 128); this.groupBox1.TabIndex = 0; this.groupBox1.TabStop = false; this.groupBox1.Text = "Auswahl"; // // radioButton1 // this.radioButton1.Location = new System.Drawing.Point(16, 24); this.radioButton1.Name = "radioButton1"; this.radioButton1.TabIndex = 0; this.radioButton1.Text = "radioButton1"; // // radioButton2 // this.radioButton2.Checked = true; this.radioButton2.Location = new System.Drawing.Point(16, 48); this.radioButton2.Name = "radioButton2"; this.radioButton2.TabIndex = 1; this.radioButton2.TabStop = true; this.radioButton2.Text = "radioButton2"; // // radioButton3 // this.radioButton3.Location = new System.Drawing.Point(16, 72); this.radioButton3.Name = "radioButton3"; this.radioButton3.TabIndex = 2; this.radioButton3.Text = "radioButton3"; // // radioButton4 // this.radioButton4.Location = new System.Drawing.Point(16, 96); this.radioButton4.Name = "radioButton4"; this.radioButton4.TabIndex = 3; this.radioButton4.Text = "radioButton4"; // // button11 // this.button11.Location = new System.Drawing.Point(8, 144); this.button11.Name = "button11"; this.button11.Size = new System.Drawing.Size(128, 24); this.button11.TabIndex = 1; this.button11.Text = "Setzen"; this.button11.Click += new System.EventHandler(this.button11_Click); // // button13 // this.button13.Location = new System.Drawing.Point(8, 168); this.button13.Name = "button13"; this.button13.Size = new System.Drawing.Size(128, 24); this.button13.TabIndex = 2; this.button13.Text = "Abfragen"; this.button13.Click += new System.EventHandler(this.button13_Click); // // checkBox1 // this.checkBox1.Location = new System.Drawing.Point(216, 32); this.checkBox1.Name = "checkBox1"; this.checkBox1.Size = new System.Drawing.Size(112, 16); this.checkBox1.TabIndex = 3; this.checkBox1.Text = "checkBox1"; // // checkBox2 // this.checkBox2.Location = new System.Drawing.Point(216, 56); this.checkBox2.Name = "checkBox2"; this.checkBox2.Size = new System.Drawing.Size(112, 16); this.checkBox2.TabIndex = 4; this.checkBox2.Text = "checkBox2"; // // checkBox3 // this.checkBox3.Location = new System.Drawing.Point(216, 80); this.checkBox3.Name = "checkBox3"; this.checkBox3.Size = new System.Drawing.Size(112, 16); this.checkBox3.TabIndex = 5; this.checkBox3.Text = "checkBox3"; // // button14 // this.button14.Location = new System.Drawing.Point(216, 168); this.button14.Name = "button14"; this.button14.Size = new System.Drawing.Size(128, 24); this.button14.TabIndex = 7; this.button14.Text = "Abfragen"; this.button14.Click += new System.EventHandler(this.button14_Click); // // button15 // this.button15.Location = new System.Drawing.Point(216, 144); this.button15.Name = "button15"; this.button15.Size = new System.Drawing.Size(128, 24); this.button15.TabIndex = 6; this.button15.Text = "Setzen"; this.button15.Click += new System.EventHandler(this.button15_Click_1); // // checkBox4 // this.checkBox4.Location = new System.Drawing.Point(216, 104); this.checkBox4.Name = "checkBox4"; this.checkBox4.Size = new System.Drawing.Size(112, 16); this.checkBox4.TabIndex = 8; this.checkBox4.Text = "checkBox4"; // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(424, 237); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.tabControl1}); this.Name = "Form1"; this.Text = "Komponenten"; this.tabControl1.ResumeLayout(false); this.tabPage1.ResumeLayout(false); this.tabPage2.ResumeLayout(false); this.tabPage3.ResumeLayout(false); this.groupBox1.ResumeLayout(false); this.ResumeLayout(false); } #endregion /// <summary> /// Der Haupteinstiegspunkt für die Anwendung. /// </summary> [STAThread] static void Main() { Application.Run(new Form1()); } private void button1_Click(object sender, System.EventArgs e) { textBox1.Text = "Ein erster Test der TextBox"; } private void button2_Click(object sender, System.EventArgs e) { textBox1.Clear(); } private void button5_Click(object sender, System.EventArgs e) { textBox1.Select(4,6); MessageBox.Show("Markierter Text: " + textBox1.SelectedText); } private void button3_Click(object sender, System.EventArgs e) { Clipboard.SetDataObject(textBox1.Text); } private void button4_Click(object sender, System.EventArgs e) { if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text)) { textBox1.Text = Clipboard.GetDataObject().GetData(DataFormats.Text).ToString(); } } private void button6_Click(object sender, System.EventArgs e) { MessageBox.Show("Erste Zeile: " + textBox1.Lines[0]); } private void button8_Click(object sender, System.EventArgs e) { listBox1.Items.Clear(); } private void button7_Click(object sender, System.EventArgs e) { listBox1.BeginUpdate(); // Anzeige ausschalten for (int i = 1; i<=10; i++) { listBox1.Items.Add("Eintrag " + i.ToString()); // 10 Einträge hinzufügen } listBox1.EndUpdate(); // Anzeige einschalten listBox1.SetSelected(0, true); // ersten Eintrag markieren } private void button12_Click(object sender, System.EventArgs e) { if (listBox1.SelectedItems.Count > 0) { int i = listBox1.SelectedIndex; // Index des Eintrags listBox1.Items.RemoveAt(i); } } private void button9_Click(object sender, System.EventArgs e) { listBox1.Items.Insert(listBox1.SelectedIndex,textBox2.Text); } private void button10_Click(object sender, System.EventArgs e) { listBox1.BeginUpdate(); // Anzeige ausschalten for (int i = 0; i<listBox1.Items.Count; i++) { listBox1.SetSelected(i, true); // ersten Eintrag markieren } listBox1.EndUpdate(); // Anzeige einschalten } private void button11_Click(object sender, System.EventArgs e) { radioButton3.Checked = true; } private void button13_Click(object sender, System.EventArgs e) { if (radioButton1.Checked) MessageBox.Show("RadioButton 1 gesetzt"); if (radioButton2.Checked) MessageBox.Show("RadioButton 2 gesetzt"); if (radioButton3.Checked) MessageBox.Show("RadioButton 3 gesetzt"); if (radioButton4.Checked) MessageBox.Show("RadioButton 4 gesetzt"); } private void button15_Click(object sender, System.EventArgs e) { } private void button15_Click_1(object sender, System.EventArgs e) { checkBox3.Checked = true; } private void button14_Click(object sender, System.EventArgs e) { if (checkBox1.Checked) MessageBox.Show("CheckBox 1 gesetzt"); if (checkBox2.Checked) MessageBox.Show("CheckBox 2 gesetzt"); if (checkBox3.Checked) MessageBox.Show("CheckBox 3 gesetzt"); if (checkBox4.Checked) MessageBox.Show("CheckBox 4 gesetzt"); } } }
Mfg