ButtonKlick???



  • Moin, Moin.
    Ich brauche ein bischen Hilfe.
    Wenn Form1 startet, ist btnPanel2 oben und btnPanel3 unten.
    So soll es auch sein. Und wenn ich auf den Button "Panel3" klicke
    geht dieser nach oben. Auch noch in Ordnung.
    Wenn ich jetzt aber die Formgröße (Form1_Resize) verändere
    geht der Button "Panel3" wieder nach unten. Das soll er nicht!!!
    Erst wenn ich wieder auf Button "Panel2" klicke soll Button "Panel3" nach unten springen.

    Kann mir jemand helfen.

    MfG
    Andreas

    /*** Anfang ***/
    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;

    namespace ButtonKlick
    {
    /// <summary>
    /// Zusammendfassende Beschreibung für Form1.
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
    private System.Windows.Forms.Panel panel1;
    private System.Windows.Forms.Panel panel2;
    private System.Windows.Forms.Button btnPanel2;
    private System.Windows.Forms.Panel panel3;
    private System.Windows.Forms.GroupBox groupBox1;
    private System.Windows.Forms.NumericUpDown numericUpDown1;
    private System.Windows.Forms.GroupBox groupBox2;
    private System.Windows.Forms.PictureBox pictureBox1;
    private System.Windows.Forms.RadioButton radioButton1;
    private System.Windows.Forms.Button btnPanel3;
    /// <summary>
    /// Erforderliche Designervariable.
    /// </summary>
    private System.ComponentModel.Container components = null;

    public Form1()
    {
    //
    // Erforderlich für die Windows Form-Designerunterstützung
    //
    InitializeComponent();
    this.panel3.Location = new System.Drawing.Point(0, this.panel2.Height-this.btnPanel3.Height);
    this.panel2.Height = this.Height;
    this.panel3.Height = this.Height;
    //
    // 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.panel1 = new System.Windows.Forms.Panel();
    this.panel2 = new System.Windows.Forms.Panel();
    this.btnPanel2 = new System.Windows.Forms.Button();
    this.panel3 = new System.Windows.Forms.Panel();
    this.btnPanel3 = new System.Windows.Forms.Button();
    this.groupBox1 = new System.Windows.Forms.GroupBox();
    this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
    this.groupBox2 = new System.Windows.Forms.GroupBox();
    this.pictureBox1 = new System.Windows.Forms.PictureBox();
    this.radioButton1 = new System.Windows.Forms.RadioButton();
    this.panel1.SuspendLayout();
    this.panel2.SuspendLayout();
    this.panel3.SuspendLayout();
    this.groupBox1.SuspendLayout();
    ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
    this.groupBox2.SuspendLayout();
    this.SuspendLayout();
    //
    // panel1
    //
    this.panel1.BackColor = System.Drawing.Color.Chartreuse;
    this.panel1.Controls.AddRange(new System.Windows.Forms.Control[] {
    this.panel2});
    this.panel1.Dock = System.Windows.Forms.DockStyle.Right;
    this.panel1.Location = new System.Drawing.Point(40, 0);
    this.panel1.Name = "panel1";
    this.panel1.Size = new System.Drawing.Size(160, 413);
    this.panel1.TabIndex = 0;
    //
    // panel2
    //
    this.panel2.BackColor = System.Drawing.Color.Turquoise;
    this.panel2.Controls.AddRange(new System.Windows.Forms.Control[] {
    this.panel3,
    this.btnPanel2,
    this.groupBox1});
    this.panel2.Dock = System.Windows.Forms.DockStyle.Right;
    this.panel2.Name = "panel2";
    this.panel2.Size = new System.Drawing.Size(160, 413);
    this.panel2.TabIndex = 0;
    //
    // btnPanel2
    //
    this.btnPanel2.BackColor = System.Drawing.SystemColors.Control;
    this.btnPanel2.Name = "btnPanel2";
    this.btnPanel2.Size = new System.Drawing.Size(160, 32);
    this.btnPanel2.TabIndex = 0;
    this.btnPanel2.Text = "Panel2";
    this.btnPanel2.Click += new System.EventHandler(this.btnPanel2_Click);
    //
    // panel3
    //
    this.panel3.AutoScroll = true;
    this.panel3.BackColor = System.Drawing.Color.SkyBlue;
    this.panel3.Controls.AddRange(new System.Windows.Forms.Control[] {
    this.groupBox2,
    this.btnPanel3});
    this.panel3.Location = new System.Drawing.Point(0, 32);
    this.panel3.Name = "panel3";
    this.panel3.Size = new System.Drawing.Size(160, 384);
    this.panel3.TabIndex = 1;
    this.panel3.Click += new System.EventHandler(this.btnPanel3_Click);
    //
    // btnPanel3
    //
    this.btnPanel3.BackColor = System.Drawing.SystemColors.Control;
    this.btnPanel3.Name = "btnPanel3";
    this.btnPanel3.Size = new System.Drawing.Size(160, 32);
    this.btnPanel3.TabIndex = 0;
    this.btnPanel3.Text = "Panel3";
    this.btnPanel3.Click += new System.EventHandler(this.btnPanel3_Click);
    //
    // groupBox1
    //
    this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
    this.numericUpDown1});
    this.groupBox1.Location = new System.Drawing.Point(16, 56);
    this.groupBox1.Name = "groupBox1";
    this.groupBox1.Size = new System.Drawing.Size(120, 248);
    this.groupBox1.TabIndex = 2;
    this.groupBox1.TabStop = false;
    this.groupBox1.Text = "groupBox1";
    //
    // numericUpDown1
    //
    this.numericUpDown1.Location = new System.Drawing.Point(32, 208);
    this.numericUpDown1.Name = "numericUpDown1";
    this.numericUpDown1.Size = new System.Drawing.Size(40, 20);
    this.numericUpDown1.TabIndex = 0;
    //
    // groupBox2
    //
    this.groupBox2.Controls.AddRange(new System.Windows.Forms.Control[] {
    this.radioButton1,
    this.pictureBox1});
    this.groupBox2.Location = new System.Drawing.Point(16, 56);
    this.groupBox2.Name = "groupBox2";
    this.groupBox2.Size = new System.Drawing.Size(120, 312);
    this.groupBox2.TabIndex = 1;
    this.groupBox2.TabStop = false;
    this.groupBox2.Text = "groupBox2";
    //
    // pictureBox1
    //
    this.pictureBox1.BackColor = System.Drawing.Color.LightSkyBlue;
    this.pictureBox1.Location = new System.Drawing.Point(24, 40);
    this.pictureBox1.Name = "pictureBox1";
    this.pictureBox1.Size = new System.Drawing.Size(64, 40);
    this.pictureBox1.TabIndex = 0;
    this.pictureBox1.TabStop = false;
    //
    // radioButton1
    //
    this.radioButton1.Location = new System.Drawing.Point(40, 280);
    this.radioButton1.Name = "radioButton1";
    this.radioButton1.Size = new System.Drawing.Size(32, 16);
    this.radioButton1.TabIndex = 1;
    this.radioButton1.Text = "radioButton1";
    //
    // Form1
    //
    this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
    this.ClientSize = new System.Drawing.Size(200, 413);
    this.Controls.AddRange(new System.Windows.Forms.Control[] {
    this.panel1});
    this.Name = "Form1";
    this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
    this.Text = "Form1";
    this.Resize += new System.EventHandler(this.btnPanel2_Click);
    this.panel1.ResumeLayout(false);
    this.panel2.ResumeLayout(false);
    this.panel3.ResumeLayout(false);
    this.groupBox1.ResumeLayout(false);
    ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
    this.groupBox2.ResumeLayout(false);
    this.ResumeLayout(false);

    }
    #endregion

    /// <summary>
    /// Der Haupteinstiegspunkt für die Anwendung.
    /// </summary>
    [STAThread]
    static void Main()
    {
    Application.Run(new Form1());
    }

    private void btnPanel2_Click(object sender, System.EventArgs e)
    {
    this.panel3.Location = new System.Drawing.Point(0, this.panel2.Height-this.btnPanel3.Height);
    this.panel3.Height = this.Height;
    }

    private void btnPanel3_Click(object sender, System.EventArgs e)
    {
    this.panel3.Location = new System.Drawing.Point(0, this.btnPanel2.Height);
    }

    private void Form1_Resize(object sender, System.EventArgs e)
    {
    this.panel3.Height = this.Height;

    }
    }
    }
    /*** Ende ***/



  • Na vielleicht, weil bei dir Resize-Ereigniss des Form auf btnPanel2_Click zeigt und nicht auf Form1_Resize...


Anmelden zum Antworten