!!!!!!!!!!!!!真是太笨了,刚想起来,Panel控件还有一个AutoScoll属性,直接修改为true即可
添加Panel控件的如下两个事件即可:
*****当然,只是添加的竖向滚动条,横向滚动条只需把VerticalScroll改为HorizontalScroll即可
/// <summary>
/// panel控件的事件:在向该控件添加控件时发生
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void pnlPlayerList_ControlAdded(object sender, ControlEventArgs e)
{
this.pnlPlayerList.VerticalScroll.Enabled = true;
this.pnlPlayerList.VerticalScroll.Visible = true;
this.pnlPlayerList.Scroll += pnlPlayerList_Scroll;
}
/// <summary>
/// panel控件的事件:用户或代码滚动工作时发生
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void pnlPlayerList_Scroll(object sender, ScrollEventArgs e)
{
this.pnlPlayerList.VerticalScroll.Value = e.NewValue;
}