I need to place icons on a map image. Since the map image is bigger than my screen resolution 1280 x 1024, a horizontal scroll bar is shown.

I use Location x and y to place icons, but the problem is: placing an icon at location (0, 0) when the horizontal scroll bar is at left-most position is different from when the horizontal scroll bar is at right-most position...

If I move scroll bar to x-axis(right) 10 then placing an icon at (0, 0), should be (0, 0) but it is placed at (10, 0).

in this case, is there any different approach? or should I consider how much scroll bar has moved? if so, how do I do it?

hope my explanation makes sense.

Thanks,

有帮助吗?

解决方案

Yes, it's sort of annoying. If your container Control supports scrolling, then you have to account for its current position whenever you set the Location on a child Control. Suppose you are using autoscroll and you want to put a child at x, y. Then your container Control could use code like this:

Point p = new Point(x, y);
p.Offset(AutoScrollPosition);
child.Location = p;
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top