user3790916
user3790916

Reputation: 51

add a vScrollBar into my form

I have the follow code and it works fine. Whenever I display the information I get a full windows but its been displayed that I have to make bigger the windows.I would like to insert a vScrollBar but I dont know how to make it work. I was able to insert it into my form but whenever I execute the windows the vScrollBar doesnt do anything

Here you have my code, thanks you all in advance

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TestData
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        public void button1_Click(object sender, EventArgs e)
        {


            com.Dashboard proxy = new com.Dashboard();


            com.ProjectMetaData[] nc = proxy.GetAllProject();


            StringBuilder sb = new StringBuilder();


            foreach (com.ProjectMetaData value in nc)
            {
                /*sb.AppendLine(string.Join("\t",value.ProjectTitle
                    + string.Join("\t",value.ProjectID)
                    + string.Join("\t",value.PublishStatus)));*/
                sb.AppendLine("\r");
                sb.AppendLine(value.ProjectTitle + "       " + value.ProjectID + "       " + value.PublishStatus);

            }
            //StringBuilder.StringBuilder();
            label1.Text = sb.ToString(); 
        }

        public void vScrollBar1_Scroll(object sender, ScrollEventArgs e)
        {

        }


    }
}

Upvotes: 1

Views: 140

Answers (1)

Syed Farjad Zia Zaidi
Syed Farjad Zia Zaidi

Reputation: 3360

This is very simple.

  1. Set your forms's AutoScroll Property to true.
  2. Now Just add some content that is larger to fit on the current screen size and you will see your vertical Scroll Bar.

Screenshot while the scroll bar is at Top.

Screenshot while the scroll bar is at top.

Screenshot while the scroll bar is at Bottom.

Screenshot while the scroll bar is at bottom.

Upvotes: 1

Related Questions