Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

C# Graphics Drawing & Scrolling

  • 17-11-2004 12:50pm
    #1
    Posts: 0


    Hey all,

    Need a bit of help regarding the subject.
    I've just really started C# but so far, I'm pleasantly surprised how close the thing is to Java, once you get around the slight differences (class layouts, event-handling, etc), it's almost the same.

    However, I remember in Java the Scrollable interface, where you could put scrolling functionality into something like a Jpanel or component...how would I get the same functionality in C#?

    My goal is to draw shapes on the screen (directly to the Graphics object) and then be able to scroll the whole screen down a bit and the drawn graphics will stay at the top, allowing me to draw more below the visible area and then scroll later.

    Hope my description is clear, any help/pointers in the right direction would be great thanks :)


Comments

  • Registered Users, Registered Users 2 Posts: 15,443 ✭✭✭✭bonkey


    You shouldn't need to code anything at all for that functionality.

    If you look at controls like Panel, they have a property (don't recall it offhand) which will autoscroll (Maybe its a boolean property called AutoScroll!) which will cause the Panel to display scrollbars whenever it contains stuff outside its drawable area.

    So, drop a Panel of size CanvasHeight,CanvasWidth into a Panel of size DisplayHeight,DisplayWidth, with AutoScroll (or whatever) set on the outer panel....et voila.

    I use a variant of the technique quite a lot, cause I draw my UI (typically boring field-based business apps) onto a Panel with MinimumSize set to something reasonable (as small as will display all controls at reasonable size), and drop the Panel onto the form. Set Dock to true, and AutoScroll on the Form to true. User can now resize the app to their hearts content, and instead of the "working area" getting shrunk too small, I get scrollbars on it.
    Using a couple of panels judiciously, I can keep things like buttons and so on visible at all times, whilst allowing the user the ability to shrink the program and use it in "scroll up and down" mode...very handy on "long" forms.

    jc


Advertisement