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.
Wich grid are you using
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.activecont rol) = "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".
If typename(screen.activecont
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
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
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!!!!