M
Hallo.
Kann sich bitte mal jemand das Benutzesteuerelement "panelContainer" anschauen?
Ich möchte unter den Button2 noch ein panelContainer2 setzen (so wie panelContainer1 unter Button1) .
Wenn ich dann das Benutzesteuerelement "panelContainer" auf meine Form1 lade, sollte beim Anklicken des Button2 auch das panelContainer2 erscheinen (nach oben rutschen)
Bekomme es aber alleine nicht hin!!!
++++++++++++++++++++++++++++++++++++++++++
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
namespace Bilder_Expand_Panel
{
public class panelContainer : System.Windows.Forms.UserControl
{
private int height = 416;
private int AnimationRate = 2;
public System.Windows.Forms.Button button1;
private System.ComponentModel.Container components = null;
public System.Windows.Forms.Panel panelContainer1;
public System.Windows.Forms.Panel panel12;
public System.Windows.Forms.Panel panel11;
public System.Windows.Forms.Panel panel10;
public System.Windows.Forms.Panel panel9;
public System.Windows.Forms.Panel panel8;
public System.Windows.Forms.Panel panel7;
public System.Windows.Forms.Panel panel6;
public System.Windows.Forms.Panel panel5;
public System.Windows.Forms.Panel panel4;
public System.Windows.Forms.Panel panel3;
public System.Windows.Forms.Panel panel2;
public System.Windows.Forms.Button button2;
public System.Windows.Forms.Panel panel1;
/// <summary>
///
public int ContentPane_HEIGHT
{
get
{
return this.height;
}
set
{
this.height = value;
}
}
/// <summary>
/// Gets/Sets Animation Rate
/// </summary>
public int Animation_Rate
{
get
{
return this.AnimationRate;
}
set
{
this.AnimationRate = value;
}
}
/// <summary>
/// Gets/Sets Content Pane
/// </summary>
public System.Windows.Forms.Panel ContentPane
{
get
{
try
{
return (Panel)this.panelContainer1.Controls[0];
}
catch(Exception e)
{
e=e;
}
return null;
}
set
{
try
{
this.panelContainer1.Controls.Clear();
this.panelContainer1.Controls.Add(value);
}
catch(Exception e)
{
e=e;
}
}
}
public panelContainer()
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
// TODO: Add any initialization after the InitializeComponent call
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.panelContainer1 = new System.Windows.Forms.Panel();
this.panel12 = new System.Windows.Forms.Panel();
this.panel11 = new System.Windows.Forms.Panel();
this.panel10 = new System.Windows.Forms.Panel();
this.panel9 = new System.Windows.Forms.Panel();
this.panel8 = new System.Windows.Forms.Panel();
this.panel7 = new System.Windows.Forms.Panel();
this.panel6 = new System.Windows.Forms.Panel();
this.panel5 = new System.Windows.Forms.Panel();
this.panel4 = new System.Windows.Forms.Panel();
this.panel3 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
this.panel1 = new System.Windows.Forms.Panel();
this.button2 = new System.Windows.Forms.Button();
this.panelContainer1.SuspendLayout();
this.SuspendLayout();
//
// button1
//
this.button1.BackColor = System.Drawing.Color.SteelBlue;
this.button1.Dock = System.Windows.Forms.DockStyle.Top;
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button1.ForeColor = System.Drawing.Color.Snow;
this.button1.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.button1.ImageIndex = 0;
this.button1.Location = new System.Drawing.Point(0, 0);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(288, 20);
this.button1.TabIndex = 0;
this.button1.Text = "Bilderrahmen I";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// panelContainer1
//
this.panelContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.panelContainer1.BackColor = System.Drawing.Color.LightSteelBlue;
this.panelContainer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.panelContainer1.Controls.Add(this.panel12);
this.panelContainer1.Controls.Add(this.panel11);
this.panelContainer1.Controls.Add(this.panel10);
this.panelContainer1.Controls.Add(this.panel9);
this.panelContainer1.Controls.Add(this.panel8);
this.panelContainer1.Controls.Add(this.panel7);
this.panelContainer1.Controls.Add(this.panel6);
this.panelContainer1.Controls.Add(this.panel5);
this.panelContainer1.Controls.Add(this.panel4);
this.panelContainer1.Controls.Add(this.panel3);
this.panelContainer1.Controls.Add(this.panel2);
this.panelContainer1.Controls.Add(this.panel1);
this.panelContainer1.DockPadding.Bottom = -10;
this.panelContainer1.ForeColor = System.Drawing.Color.SteelBlue;
this.panelContainer1.Location = new System.Drawing.Point(0, 20);
this.panelContainer1.Name = "panelContainer1";
this.panelContainer1.Size = new System.Drawing.Size(288, 372);
this.panelContainer1.TabIndex = 1;
//
// panel12
//
this.panel12.BackColor = System.Drawing.Color.White;
this.panel12.Cursor = System.Windows.Forms.Cursors.Hand;
this.panel12.Location = new System.Drawing.Point(16, 16);
this.panel12.Name = "panel12";
this.panel12.Size = new System.Drawing.Size(72, 72);
this.panel12.TabIndex = 52;
//
// panel11
//
this.panel11.BackColor = System.Drawing.Color.White;
this.panel11.Cursor = System.Windows.Forms.Cursors.Hand;
this.panel11.Location = new System.Drawing.Point(104, 16);
this.panel11.Name = "panel11";
this.panel11.Size = new System.Drawing.Size(72, 72);
this.panel11.TabIndex = 51;
//
// panel10
//
this.panel10.BackColor = System.Drawing.Color.White;
this.panel10.Cursor = System.Windows.Forms.Cursors.Hand;
this.panel10.Location = new System.Drawing.Point(192, 16);
this.panel10.Name = "panel10";
this.panel10.Size = new System.Drawing.Size(72, 72);
this.panel10.TabIndex = 50;
//
// panel9
//
this.panel9.BackColor = System.Drawing.Color.White;
this.panel9.Cursor = System.Windows.Forms.Cursors.Hand;
this.panel9.Location = new System.Drawing.Point(16, 104);
this.panel9.Name = "panel9";
this.panel9.Size = new System.Drawing.Size(72, 72);
this.panel9.TabIndex = 49;
//
// panel8
//
this.panel8.BackColor = System.Drawing.Color.White;
this.panel8.Cursor = System.Windows.Forms.Cursors.Hand;
this.panel8.Location = new System.Drawing.Point(104, 104);
this.panel8.Name = "panel8";
this.panel8.Size = new System.Drawing.Size(72, 72);
this.panel8.TabIndex = 48;
//
// panel7
//
this.panel7.BackColor = System.Drawing.Color.White;
this.panel7.Cursor = System.Windows.Forms.Cursors.Hand;
this.panel7.Location = new System.Drawing.Point(192, 104);
this.panel7.Name = "panel7";
this.panel7.Size = new System.Drawing.Size(72, 72);
this.panel7.TabIndex = 47;
//
// panel6
//
this.panel6.BackColor = System.Drawing.Color.White;
this.panel6.Cursor = System.Windows.Forms.Cursors.Hand;
this.panel6.Location = new System.Drawing.Point(16, 192);
this.panel6.Name = "panel6";
this.panel6.Size = new System.Drawing.Size(72, 72);
this.panel6.TabIndex = 46;
//
// panel5
//
this.panel5.BackColor = System.Drawing.Color.White;
this.panel5.Cursor = System.Windows.Forms.Cursors.Hand;
this.panel5.Location = new System.Drawing.Point(104, 192);
this.panel5.Name = "panel5";
this.panel5.Size = new System.Drawing.Size(72, 72);
this.panel5.TabIndex = 45;
//
// panel4
//
this.panel4.BackColor = System.Drawing.Color.White;
this.panel4.Cursor = System.Windows.Forms.Cursors.Hand;
this.panel4.Location = new System.Drawing.Point(192, 192);
this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(72, 72);
this.panel4.TabIndex = 44;
//
// panel3
//
this.panel3.BackColor = System.Drawing.Color.White;
this.panel3.Cursor = System.Windows.Forms.Cursors.Hand;
this.panel3.Location = new System.Drawing.Point(16, 280);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(72, 72);
this.panel3.TabIndex = 43;
//
// panel2
//
this.panel2.BackColor = System.Drawing.Color.White;
this.panel2.Cursor = System.Windows.Forms.Cursors.Hand;
this.panel2.Location = new System.Drawing.Point(104, 280);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(72, 72);
this.panel2.TabIndex = 42;
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.White;
this.panel1.Cursor = System.Windows.Forms.Cursors.Hand;
this.panel1.Location = new System.Drawing.Point(192, 280);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(72, 72);
this.panel1.TabIndex = 41;
//
// button2
//
this.button2.BackColor = System.Drawing.Color.SteelBlue;
this.button2.Dock = System.Windows.Forms.DockStyle.Bottom;
this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button2.ForeColor = System.Drawing.Color.Snow;
this.button2.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.button2.ImageIndex = 0;
this.button2.Location = new System.Drawing.Point(0, 396);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(288, 20);
this.button2.TabIndex = 2;
this.button2.Text = "Bilderrahmen II";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// panelContainer
//
this.BackColor = System.Drawing.Color.AliceBlue;
this.Controls.Add(this.button2);
this.Controls.Add(this.panelContainer1);
this.Controls.Add(this.button1);
this.Name = "panelContainer";
this.Size = new System.Drawing.Size(288, 416);
this.Resize += new System.EventHandler(this.panelContainer_Resize);
this.Load += new System.EventHandler(this.panelContainer_Load);
this.panelContainer1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void panelContainer_Resize(object sender, System.EventArgs e)
{
if(AnimationRate==1)
return;
if((this.Height%2)!=0)
this.Height+=1;
}
private void panelContainer_Load(object sender, System.EventArgs e)
{
this.Height = this.height+this.button1.Height;
}
private void button1_Click(object sender, System.EventArgs e)
{
if(this.Height==this.button1.Height*2)//aufmachen
{
int x = this.button1.Height*2+this.height;
while(this.Height<=(x))
{
Application.DoEvents();
//Rate of Increment
//this.Height +=2;
this.Height +=AnimationRate;
}
this.button1.ImageIndex = 0;
this.Height = x;
}
}
private void button2_Click(object sender, System.EventArgs e)
{
if(this.Height>this.button1.Height2)//zumachen
{
while(this.Height>this.button1.Height2)
{
Application.DoEvents();
//Rate of Decrement
//this.Height -=2;
this.Height -=AnimationRate;
}
this.button1.ImageIndex = 1;
this.Height = this.button1.Height*2;
}
else if(this.Height==this.button1.Height*2)//aufmachen
{
int x = this.button1.Height*2+this.height;
while(this.Height<=(x))
{
Application.DoEvents();
//Rate of Increment
//this.Height +=2;
this.Height +=AnimationRate;
}
this.button1.ImageIndex = 0;
this.Height = x;
}
}
}
}
++++++++++++++++++++++++++++++++++++++++++