C# Tutorial for KetticScrollBar control for Windows Forms
KetticScrollBar control for Windows Forms provides HoriScrollBar and VertiScrollBar to replace the standard Windows Forms scroll bar elements to create scrolling bars in horizontal and vertical orientation for your applications. The scrolling element of VertiScrollViewer allows users fully manage the content area and can be applied when it is necessary. The VertiScrollViewer supports Physical mode, which customize the scrolling in preset intervals, and Logical scrolling mode, which customize the size of the increment.
C# Tutorial for Using KetticScrollBar control for Windows Forms
To using the KetticScrollBar, we shall handle the scroll events in .NET project. The following steps demonstrate how to use the two panels to implement scrolling for the content of the second panel.
- Open an existing .NET project or create a new one in your Visual Studio
- Drag a KetticPanel control from the toolbox and drop it on the form, and apply the Office2007Blue theme to the panels
- Add a KetticVertiScrollBar and dock it to the Right in the panel and then add another KetticPanel to the newly added KetticVertiScrollBar
- Set the height of the KetticPanel to the total height that is available upon scrolling as your requirement.
- And then we shall add controls to the second KetticPanel with the C# code below. Alternatively, we can drag and drop the controls to the KetticPanel at design time.
for (int i = 1; i < 15; i++)
KetticButton button = new KetticButton();
button.Location = new Point(30, i * 30 + 5 * i);
button.Size = new Size(70, 30);
button.Text = "KetticButton" + i.ToString();
- After the above setting, we can subscribe to the Scroll event of the vertical scroll bar. And then use the C# code snippet below to assign its negated value to the Top property of the second KetticPanel
void ketticVScrollBar1_Scroll(object sender, ScrollEventArgs e)
this.ketticPanel2.Top = -this.ketticVScrollBar1.Value;
- Finally, we can set the Maximum property of the scrollbar with the C# code below. The setting will reflect the size of the scrollable height.
this.ketticVScrollBar1.Maximum = this.ketticPanel2.Size.Height - this.ketticPanel1.Size.Height;