Question : vb.net panel scroll with picture box

Hi Experts,

I have a panel and a pictuerbox with a picture of a ruler on it.  The problem is when I scroll the panlel up and down the ruler/picturebox goes off the panel so you cant see it. I need some way keep the picturebox fixed in the Y / up and down direction/location, I still want it to scroll in the right to left direction.   I'm think something like what WordPad does.

Thanks
Richard

Answer : vb.net panel scroll with picture box

Hi,

I posted the solution file this time.

I also added the Application.DoEvents() to the code that moves the panel controls.

I used panel controls for my ruler container and grid container. Panel controls can host child controls, and those child controls will move along with their parent (panel) control. This is why the numbers on the ruler move even though the numbers are actually on a label control. The DoEvents() prevents some of the flicker.

Of course, my app is a demo only. You can refine it to suit your taste.

One final point: I have my scrollbars set to a min of 0 and a max of 100. This is nice because it translates to a percent. But to make effective use of scrollbars you may want to use a larger max and also tie the horiz scrollbar to the width of the grid panel and the ruler panel as the vscrollbar max to the height of the grid panel.

(BTW: It's not easy to upload a project solution here! The uploader won't allow .settings, .user, .suo, or other file types, so there was a lot of trial and error just getting the demo uploaded...... I have to learn an easier way to share a solution!)

Good luck,
Jon500
 
Scrolling Grid Demo
 
Random Solutions  
 
programming4us programming4us