Keep Moving Objects Between Lines in a Panel.

JimboIII

New member
Joined
Jun 17, 2009
Messages
3
Programming Experience
1-3
I've put this small project together with examples I've found on this site (attached). I have two squares (Class called mover) that can be moved left and right. They are contained within a panel. I'm trying to keep the two squares between two red lines in the panel. One problem is that when the panel is scrolled, the bounds I'm trying to setup move with the scroll. The second problem I'm having is that I can't seem to access Panel.HorizontalScroll.Value when using a form that's a childform of an MDIParent.

You can see what I mean by running the app. Clicking the Help icon on ToolStrip will open Form1. Then clicking Button1 on Form1 will populate the boxes.

The project requirements state I need the scrollable panel and that this form must be done in an MDI environment. Hopefully this is easier to do than I'm making it.

Thanks for any help
 

Attachments

  • TestBed.zip
    34.2 KB · Views: 37
Last edited by a moderator:
Any ideas on this one? I'd be willing to hear some outside the box suggestions for this. I've got nothing, still...

Thanks
 
The action of a panel's scrollbars is to scroll any controls which are hosted in the panel. If you don't want the lines to scroll, draw them in the panel's Paint event handler with e.Graphics.DrawLine.

all the best, BB
 
If a control has focus and you scroll down or up if it leave the visible area it may and often does cause the scroll to move it back into focus. The way to fix this it to set the focus to something else - like the panel - when you are scrolling.
 
Back
Top