零-点

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
/// <summary>
/// panel控件的事件:在向该控件添加控件时发生
/// </summary>
private void panel1_ControlAdded(object sender, ControlEventArgs e)
{
	panel1.AutoScroll = true;
	panel1.VerticalScroll.Enabled = true;
	panel1.VerticalScroll.Visible = true;
	panel1.Scroll += panel1_Scroll;
}

/// <summary>
/// panel控件的事件:用户或代码滚动工作时发生  
/// </summary>
void panel1_Scroll(object sender, ScrollEventArgs e)
{
	this.panel1.VerticalScroll.Value = e.NewValue;
}
private void Load(object sender, EventArgs e)
{
      //注册panel1事件
	this.panel1.ControlAdded += panel1_ControlAdded;
	for (int i = 0; i< 30; i++)
	{
		PictureBox pictureBox1 = new PictureBox();
		pictureBox1.Cursor = Cursors.Hand;
		pictureBox1.Dock = DockStyle.Top;
		pictureBox1.Size = new Size(0, 100);
		pictureBox1.TabStop = false;
		pictureBox1.BorderStyle = BorderStyle.FixedSingle;
		this.panel1.Controls.Add(pictureBox1);
	}
}

  

posted on 2017-03-11 20:52  零-点  阅读(2668)  评论(0编辑  收藏  举报