How to make a grid control scroll down via program.

Posted on 1998-09-29
Last Modified: 2010-04-30
I am developing a screen with a grid control (not dbgrid control). I have enabled a vertical scroll bar since the number of rows is large. How do I scroll down the grid via code to make a row visible ? Is there a method for this ? I can't see any under vb help option. Thanks.
Question by:kkandasa
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 1437258
Wich grid are you using

Accepted Solution

CarlosJac earned 50 total points
ID: 1437259

SendKeys "{DOWN}"

Expert Comment

ID: 1437260
If you would like to scroll down slowly ( as if a user is clicking by mouse), you can put a timer control on your form. Set the timer interval property to 2500 ( 1/4 seconds ) then on the timer click event, enter following code:

If typename(screen.activecontrol) = "your Grid control name" then
    sendkeys "{DOWN}"
   sendkeys "{DOWN}"
End if

NOTE: If you used dbGrid, then the part "your Grid control name" will be "dbGrid".

Expert Comment

ID: 1437261
To position row 20 at the top of the grid programmatically use;

If you want it part way down or something, subtract a few rows from the desired position. Ex, grid is 20 rows tall and you want to scroll to put item 112 in the middle use;

Author Comment

ID: 1437262
Thank you for your answer. I also got another answer where I can get set the toprow property to have the same effect. This site is great!!!!

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month2 days, 18 hours left to enroll

621 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