0

I am trying to create a custom scroll bar for my panel. The thing is that when i am scrolling it conflicts with Default Panel Scroll Bar.

     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;
        }
    }

When i am scrolling it changes my size of scrollbar and also it appears default panel Scroll Bar.

enter image description here

Dim
  • 433
  • 1
  • 9
  • 23
  • WinForms/WPF/something else? Is VScrollBar your own class? – ProgrammingLlama Feb 06 '19 at 07:55
  • 1
    You didn't even mention which stack you use. Winforms? WFP? In WinForms, [VScrollbar](https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.vscrollbar?view=netframework-4.7.2) is meant `to implement scrolling in containers that do not provide their own scroll bars such as a PictureBox or for user input of numeric data.`. Your container already *has* a scrollbar, it's not just some default. BTW what container is that? – Panagiotis Kanavos Feb 06 '19 at 07:56
  • What container are you using? Have you tried customizing that container? – Panagiotis Kanavos Feb 06 '19 at 07:57
  • You can't modify the built-in scrollbar in WinForms. You have to hide it and handle scrolling on your own. WPF on the other hand supports styling out of the box – Panagiotis Kanavos Feb 06 '19 at 08:07

0 Answers0