mmh also ich hab den Code etwas überarbeitet. Ja es ist eigentlich ein Windows.Form mit 12 Checkboxen und einem Button.
der neue Code und weiter unten das Formular. Funzt leider immer nich garnicht
. Wie kann ich die boxen aus dem Formular auslesen?
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace WindowsApplication1
{
static class Program
{
/// <summary>
/// Der Haupteinstiegspunkt für die Anwendung.
/// </summary>
[STAThread]
static void Main()
{
CheckBox[] chkarray1 = new CheckBox[checkBox()];
CheckBox[] chkarray2 = new CheckBox[checkBox()];
for (int i = 0; i < 7; i++)
{
if (chkarray1[i].Checked){
Console.WriteLine("CheckBox"+chkarray1[i]+": checked");
} else {
Console.WriteLine("CheckBox"+chkarray1[i]+": not checked");
}
}
for (int i = 7; i < 13; i++)
{
if (chkarray2[i].Checked)
{
Console.WriteLine("CheckBox" + chkarray2[i] + ": checked");
} else {
Console.WriteLine("CheckBox" + chkarray2[i] + ": not checked");
}
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
private static object checkBox()
{
throw new Exception("The method or operation is not implemented.");
}
}
}
Windows.Form
namespace WindowsApplication1
{
partial class Form1
{
/// <summary>
/// Erforderliche Designervariable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Verwendete Ressourcen bereinigen.
/// </summary>
/// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Vom Windows Form-Designer generierter 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.checkBox1 = new System.Windows.Forms.CheckBox();
this.checkBox2 = new System.Windows.Forms.CheckBox();
this.checkBox3 = new System.Windows.Forms.CheckBox();
this.checkBox4 = new System.Windows.Forms.CheckBox();
this.checkBox5 = new System.Windows.Forms.CheckBox();
this.checkBox6 = new System.Windows.Forms.CheckBox();
this.checkBox7 = new System.Windows.Forms.CheckBox();
this.checkBox8 = new System.Windows.Forms.CheckBox();
this.checkBox9 = new System.Windows.Forms.CheckBox();
this.checkBox10 = new System.Windows.Forms.CheckBox();
this.checkBox11 = new System.Windows.Forms.CheckBox();
this.button1 = new System.Windows.Forms.Button();
this.checkBox12 = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(12, 12);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(80, 17);
this.checkBox1.TabIndex = 0;
this.checkBox1.Text = "checkBox1";
this.checkBox1.UseVisualStyleBackColor = true;
//
// checkBox2
//
this.checkBox2.AutoSize = true;
this.checkBox2.Location = new System.Drawing.Point(98, 12);
this.checkBox2.Name = "checkBox2";
this.checkBox2.Size = new System.Drawing.Size(80, 17);
this.checkBox2.TabIndex = 1;
this.checkBox2.Text = "checkBox2";
this.checkBox2.UseVisualStyleBackColor = true;
//
// checkBox3
//
this.checkBox3.AutoSize = true;
this.checkBox3.Location = new System.Drawing.Point(184, 12);
this.checkBox3.Name = "checkBox3";
this.checkBox3.Size = new System.Drawing.Size(80, 17);
this.checkBox3.TabIndex = 2;
this.checkBox3.Text = "checkBox3";
this.checkBox3.UseVisualStyleBackColor = true;
//
// checkBox4
//
this.checkBox4.AutoSize = true;
this.checkBox4.Location = new System.Drawing.Point(270, 12);
this.checkBox4.Name = "checkBox4";
this.checkBox4.Size = new System.Drawing.Size(80, 17);
this.checkBox4.TabIndex = 3;
this.checkBox4.Text = "checkBox4";
this.checkBox4.UseVisualStyleBackColor = true;
//
// checkBox5
//
this.checkBox5.AutoSize = true;
this.checkBox5.Location = new System.Drawing.Point(356, 12);
this.checkBox5.Name = "checkBox5";
this.checkBox5.Size = new System.Drawing.Size(80, 17);
this.checkBox5.TabIndex = 4;
this.checkBox5.Text = "checkBox5";
this.checkBox5.UseVisualStyleBackColor = true;
//
// checkBox6
//
this.checkBox6.AutoSize = true;
this.checkBox6.Location = new System.Drawing.Point(442, 12);
this.checkBox6.Name = "checkBox6";
this.checkBox6.Size = new System.Drawing.Size(80, 17);
this.checkBox6.TabIndex = 5;
this.checkBox6.Text = "checkBox6";
this.checkBox6.UseVisualStyleBackColor = true;
//
// checkBox7
//
this.checkBox7.AutoSize = true;
this.checkBox7.Location = new System.Drawing.Point(12, 67);
this.checkBox7.Name = "checkBox7";
this.checkBox7.Size = new System.Drawing.Size(80, 17);
this.checkBox7.TabIndex = 6;
this.checkBox7.Text = "checkBox7";
this.checkBox7.UseVisualStyleBackColor = true;
//
// checkBox8
//
this.checkBox8.AutoSize = true;
this.checkBox8.Location = new System.Drawing.Point(98, 67);
this.checkBox8.Name = "checkBox8";
this.checkBox8.Size = new System.Drawing.Size(80, 17);
this.checkBox8.TabIndex = 7;
this.checkBox8.Text = "checkBox8";
this.checkBox8.UseVisualStyleBackColor = true;
//
// checkBox9
//
this.checkBox9.AutoSize = true;
this.checkBox9.Location = new System.Drawing.Point(184, 67);
this.checkBox9.Name = "checkBox9";
this.checkBox9.Size = new System.Drawing.Size(80, 17);
this.checkBox9.TabIndex = 8;
this.checkBox9.Text = "checkBox9";
this.checkBox9.UseVisualStyleBackColor = true;
//
// checkBox10
//
this.checkBox10.AutoSize = true;
this.checkBox10.Location = new System.Drawing.Point(270, 67);
this.checkBox10.Name = "checkBox10";
this.checkBox10.Size = new System.Drawing.Size(86, 17);
this.checkBox10.TabIndex = 9;
this.checkBox10.Text = "checkBox10";
this.checkBox10.UseVisualStyleBackColor = true;
//
// checkBox11
//
this.checkBox11.AutoSize = true;
this.checkBox11.Location = new System.Drawing.Point(356, 67);
this.checkBox11.Name = "checkBox11";
this.checkBox11.Size = new System.Drawing.Size(86, 17);
this.checkBox11.TabIndex = 10;
this.checkBox11.Text = "checkBox11";
this.checkBox11.UseVisualStyleBackColor = true;
//
// button1
//
this.button1.Location = new System.Drawing.Point(210, 213);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 11;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// checkBox12
//
this.checkBox12.AutoSize = true;
this.checkBox12.Location = new System.Drawing.Point(449, 67);
this.checkBox12.Name = "checkBox12";
this.checkBox12.Size = new System.Drawing.Size(86, 17);
this.checkBox12.TabIndex = 12;
this.checkBox12.Text = "checkBox12";
this.checkBox12.UseVisualStyleBackColor = true;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(556, 273);
this.Controls.Add(this.checkBox12);
this.Controls.Add(this.button1);
this.Controls.Add(this.checkBox11);
this.Controls.Add(this.checkBox10);
this.Controls.Add(this.checkBox9);
this.Controls.Add(this.checkBox8);
this.Controls.Add(this.checkBox7);
this.Controls.Add(this.checkBox6);
this.Controls.Add(this.checkBox5);
this.Controls.Add(this.checkBox4);
this.Controls.Add(this.checkBox3);
this.Controls.Add(this.checkBox2);
this.Controls.Add(this.checkBox1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.CheckBox checkBox2;
private System.Windows.Forms.CheckBox checkBox3;
private System.Windows.Forms.CheckBox checkBox4;
private System.Windows.Forms.CheckBox checkBox5;
private System.Windows.Forms.CheckBox checkBox6;
private System.Windows.Forms.CheckBox checkBox7;
private System.Windows.Forms.CheckBox checkBox8;
private System.Windows.Forms.CheckBox checkBox9;
private System.Windows.Forms.CheckBox checkBox10;
private System.Windows.Forms.CheckBox checkBox11;
private System.Windows.Forms.CheckBox checkBox12;
private System.Windows.Forms.Button button1;
}
}