tags:

views:

19

answers:

1

I have a form, where there is horizontal scroll bar and beneath it, a label at the bottom. I have applied a zoom utility here, that is whenever I press zoom once the label grows 1.1 times in size and so on. The horizontal scroll bar remains of the same size but its location changes according to the label as per zooming, that is it keeps shifting as the label expands or contracts according to zoom. The scroll bar is stuck with the label.

Now the problem I face is that when I zoom, the zooming takes place fine but the location of the label changes abnormally. It shifts up on zooming but shifts too much. The distance between the bottom and the label is much greater than the distance between the horizontal scroll bar and the label.

I am using this code to set the location of the label on the form:

label.Location = new Point(label.Location.X, this.Height - label.Size.Height);

How to zoom it uniformly so that the distance that is zoomed over and below the label is uniform and equal? The horizontal scroll bar moves fine and is stuck above the label.

A: 

It sounds like you need to consider the AutoScrollPosition property of your scrolling container. You may want to reset that to (0,0) before you reset the location of your label. When you are scrolled, the top left corner of the visible client area is treated as the origin, not the "true" top left corner of the un-scrolled container.

For example:

container.AutoScrollPosition = new Point( 0, 0 );
label.Location = new Point( 0, 0 );
Ed Swangren