C#: Scroll to specific place in panel

thesadguy

Active Member
Joined
Nov 29, 2008
Messages
70
Reaction score
0
Hi all

I have a panel with
Code:
AutoScroll = true;

I would like to be able to scroll to a specific place; whether it be to bring a specific control into view, or to a specific part of the scrolled pane (a percentage perhaps?) or a certain number of scroll steps down or up, or perhaps even similar to the way html handles links to certain places, like
Code:
http://url.domain.com/index.php#here

I've read up on the ScrollControlIntoView method, but can't seem to get it to work :(

Does anyone have any idea how it works? Or any other ideas on how to programmatically scroll a panel?
 
do you want anchor functionality? as in e.g. "Go To Top"?

easiest would be standard html anchors. <a id="top"></a> being the destination and <a href="#top">Go To Top</a> being your link

obviously, using a URL can link directly to an anchor, like www.mysite.com/default.htm#top

is this what you are referring to?

EDIT: come to think of it, C# controls have a .Focus() but for the life of me I cannot remember if it autoscrolls to that position of the page. and this will have to happen on a postback
 
Last edited:
Well, assuming you are using ASP.NET and not a Windows forms app, there are various ways. Either use the controlId.focus() of the specific control to automatically scroll the panel to get the control into view, or set the scrollTop of the panel to a specific amount of pixels, i.e. panelId.scrollTop = "20px" to "scroll" the panel 20 pixels. This needs to happen client-side though...
 
Top
Sign up to the MyBroadband newsletter
X