C# WinForms - Scroll in a DataGrid

Posted on 2007-07-27
Last Modified: 2010-02-13

I'm displaying a lots of columns in a WinForms DataGrid control.

My columns are so many that they're all squashed up against each other.

The problem is that I can't seem to find some kind of property like a scrollbar or something. Isn't there a property on the DataGrid that enables a scrollbar?

Thank you.
Question by:Endelm

    Author Comment

    My DataGrid control is:

    Author Comment

    I'm talking about horizontal scrolling of the DataGridView control.
    LVL 20

    Accepted Solution

    what I would do is place your DataGridView inside a panel.  Then Add a HScrollBar to the panel.  You would have to add the programming to the ScrollBar but that would be perfect for your needs.  

    Even further than that you can simply manipulate the left value of your DataGridView inside your panel.  Test this by giving your DataGridView inside your panel a Left of says -50 .

    Add your own buttons for GUI, or add a scroll bar.  You have many options to achieve this



    Author Comment

    Thank you REA_ANDREW.

    What property is the scroll bar changing?

    Thank you.
    LVL 7

    Expert Comment

    dataGridView1.ScrollBars = ScrollBars.Both;

    Also handy:
    dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
    AllCells is slow but other values are also possible.

    Kind regards,

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    This is about my first experience with programming Arduino.
    Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now