Link to home
Start Free TrialLog in
Avatar of kkandasa
kkandasa

asked on

How to make a grid control scroll down via program.

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.
Avatar of dabellei
dabellei

Wich grid are you using
ASKER CERTIFIED SOLUTION
Avatar of CarlosJac
CarlosJac

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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}"
Else
   myGrid.Setfocus
   sendkeys "{DOWN}"
End if

NOTE: If you used dbGrid, then the part "your Grid control name" will be "dbGrid".
To position row 20 at the top of the grid programmatically use;
Grid1.TopRow=20

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;
Grid1.TopRow=102
Avatar of kkandasa

ASKER

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!!!!