C# Windows Forms HScrollBar Examples

Let us look at a simple C# Windows Forms HScrollBar example.

Example 1: HScrollBar

This example will comprise the following files:

  • HScrollBar.cs

Step 1: Create Project

  1. The first step is to create a C# Project.
  2. Go to FILE-->New-->Project to create a new project.

Step 2: Write Code

Write Code as follows:

*(a). HScrollBar.cs

Create a file named HScrollBar.cs

Here is the full code

using System;
using System.Windows.Forms;

namespace Examples {
  class MainForm : Form {
    public static void Main() {
      Application.Run(new MainForm());

    public MainForm() {
      Text = "HScrollBar example";

      scrollBar1.Parent = this;
      scrollBar1.Location = new System.Drawing.Point(30, 40);

      scrollBar2.Parent = this;
      scrollBar2.Location = new System.Drawing.Point(30, 80);
      scrollBar2.Minimum = 0;
      scrollBar2.Value = 100;
      scrollBar2.Maximum = 200;
      scrollBar2.Width = 220;

    private HScrollBar scrollBar1 = new HScrollBar();
    private HScrollBar scrollBar2 = new HScrollBar();


Simply copy the source code into your C# Project,Build and Run. Alternatively download the code using the links provided below, then open the .csproj project, build and run.


Download the code using the below links:

Number Link
1. Download Example
2. Follow code author

Related Posts