Panel1 scrollen?

Moin Moin,
ich möchte Panel1 scrollen. So das der Button1 zu sehen ist.
Kann mir bitte jemand helfen???

Mit freundlichem Gruß
Andreas

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

namespace Scrolltest
{
///
/// Zusammendfassende Beschreibung für Form1.
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.VScrollBar vScrollBar1;
private System.Windows.Forms.Panel Panel1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Button button1;
///
/// Erforderliche Designervariable.
///
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
//
}

///
/// Die verwendeten Ressourcen bereinigen.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
///
/// Erforderliche Methode für die Designerunterstützung.
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
///
private void InitializeComponent()
{
this.Panel1 = new System.Windows.Forms.Panel();
this.button1 = new System.Windows.Forms.Button();
this.vScrollBar1 = new System.Windows.Forms.VScrollBar();
this.panel2 = new System.Windows.Forms.Panel();
this.Panel1.SuspendLayout();
this.panel2.SuspendLayout();
this.SuspendLayout();
//
// Panel1
//
this.Panel1.BackColor = System.Drawing.Color.LightCoral;
this.Panel1.Controls.AddRange(new System.Windows.Forms.Control[] {
this.button1});
this.Panel1.Location = new System.Drawing.Point(24, 8);
this.Panel1.Name = „Panel1“;
this.Panel1.Size = new System.Drawing.Size(152, 400);
this.Panel1.TabIndex = 0;
//
// button1
//
this.button1.Location = new System.Drawing.Point(24, 360);
this.button1.Name = „button1“;
this.button1.Size = new System.Drawing.Size(88, 32);
this.button1.TabIndex = 0;
this.button1.Text = „button1“;
//
// vScrollBar1
//
this.vScrollBar1.Dock = System.Windows.Forms.DockStyle.Right;
this.vScrollBar1.Location = new System.Drawing.Point(184, 0);
this.vScrollBar1.Name = „vScrollBar1“;
this.vScrollBar1.Size = new System.Drawing.Size(16, 344);
this.vScrollBar1.TabIndex = 1;
this.vScrollBar1.ValueChanged += new System.EventHandler(this.vScrollBar1_ValueChanged);
//
// panel2
//
this.panel2.BackColor = System.Drawing.Color.SkyBlue;
this.panel2.Controls.AddRange(new System.Windows.Forms.Control[] {
this.Panel1,
this.vScrollBar1});
this.panel2.Location = new System.Drawing.Point(8, 8);
this.panel2.Name = „panel2“;
this.panel2.Size = new System.Drawing.Size(200, 344);
this.panel2.TabIndex = 2;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(240, 389);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.panel2});
this.Name = „Form1“;
this.Text = „Form1“;
this.Panel1.ResumeLayout(false);
this.panel2.ResumeLayout(false);
this.ResumeLayout(false);

}
#endregion

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

private void vScrollBar1_ValueChanged(object sender, System.EventArgs e)
{
/*** ??? ***/
}
}
}

Hallo Andreas,

ich habe Deinen Source mal in ein neues Projekt gezogen. Was mich irritiert, ist, dass Du auch noch ein panel2 hast, in dem panel1 ist, in dem wiederum sich der Button befindet. Falls Du auf panel2 verzichten kannst, solltest Du panel1 direkt auf die Form setzen. Trotzdem solltest Du alle Panels auf AutoScroll=true setzen, sofern sich darin Controls befinden, die u.U. aus dem Sichtbarkeitsbereich verschwinden.

Geholfen? Gruß
Thomas

Moin Moin,
ich möchte Panel1 scrollen. So das der Button1 zu sehen ist.
Kann mir bitte jemand helfen???

Mit freundlichem Gruß
Andreas

Danke (ein hab ich noch) ;o)
Hallo Thomas,
habs grad probiert. Danke. Es geht!!!

Andreas

PS: kann man dieser Auto-ScrollBar einen anderen Style zuweisen???

Soweit ich das weiß, geht da nix, es sei denn, Du willst das Paint-Ereignis des Panels selbst ausprogrammieren.

Gruß
Thomas

[Bei dieser Antwort wurde das Vollzitat nachträglich automatisiert entfernt]