我正在尝试为面板创建自定义滚动条。事实是,当我滚动时,它与“默认面板滚动条”冲突。
VScrollBar vScrollBar1 = new VScrollBar();
vScrollBar1.Dock = DockStyle.Right;
vScrollBar1.Width = 30;
vScrollBar1.Scroll += VScrollBar1_Scroll;
pnlUserWorkTime.Controls.Add(vScrollBar1);
private void pnlUserWorkTime_Scroll(object sender, ScrollEventArgs e)
{
if (pnlUserWorkTime.Controls.Count > 0 )
{
vScrollBar1.Value = e.NewValue;
}
}
private void VScrollBar1_Scroll(object sender, ScrollEventArgs e)
{
if (pnlUserWorkTime.Controls.Count > 0)
{
pnlUserWorkTime.VerticalScroll.Value = e.NewValue;
}
}
当我滚动时,它会更改滚动条的大小,并且还会显示默认面板“滚动条”。