2

I have one form that is having Scrollbar, i want to disable the scroll button that is present in vertical scroll bar with single click up and down movement buttons working...

can any one help me in this?

2 Answers2

0

Try this ...

VScrollBar vsb = DataGridView1.Controls.OfType(Of(VScrollBar)).SingleOrDefault;

vsb.LargeChange = vsb.SmallChange;   
matzone
  • 5,703
  • 3
  • 17
  • 20
  • matzone thanks for reply... actually i have one gridview that is created during runtime, if the no of rows inside it are more then its size the vertical scrollbar is visible in that scroll bar i want to disable sroll.. –  Jun 05 '13 at 08:18
  • This makes little sense, just add fewer rows. – Hans Passant Jun 05 '13 at 11:43
0

You will find the answer here: Hide vertical scroll bar in ListBox control

Basically, you cannot hide it. You can only make it always show or auto show if it is needed. Otherwise, you may need to make a custom control to do what you want.

The link also shows you how to create a class library to do this (taken directly from the link):

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ClassLibrary1
{
    public class MyListBox : System.Windows.Forms.ListBox
    {
        private bool mShowScroll;
        protected override System.Windows.Forms.CreateParams CreateParams
        {
            get
            {
                CreateParams cp = base.CreateParams;
                if (!mShowScroll)
                    cp.Style = cp.Style & ~0x200000;
                return cp;
            }
        }
        public bool ShowScrollbar
        {
            get { return mShowScroll; }
            set
            {
                if (value == mShowScroll)
                    return;
                mShowScroll = value;
                if (Handle != IntPtr.Zero)
                    RecreateHandle();
            }
        }
    }    
}
Community
  • 1
  • 1
Mike
  • 346
  • 2
  • 10