[C# Helper]
Index Books FAQ Contact About Rod
[Beginning Database Design Solutions, Second Edition]

[Beginning Software Engineering, Second Edition]

[Essential Algorithms, Second Edition]

[The Modern C# Challenge]

[WPF 3d, Three-Dimensional Graphics with WPF and C#]

[The C# Helper Top 100]

[Interview Puzzles Dissected]

[C# 24-Hour Trainer]

[C# 5.0 Programmer's Reference]

[MCSD Certification Toolkit (Exam 70-483): Programming in C#]

Title: Allow scrolling while making a hexagonal montage in C#

[Allow scrolling while making a hexagonal montage in C#]

The example Make a hexagonal montage of pictures in C# shows how to make a hexagonal montage similar to the one shown above. I sometimes want to make a montage that is much bigger, and that example doesn't let you do that. There are two obvious approaches. First, you could draw the montage at one scale and then save it at another. Second, you could let the user scroll the montage.

If you take the first approach, then you would need to convert mouse clicks for the scaled result. This is possible, but more work than the second approach, which is practically trivial. This example simply moves the picGrid PictureBox control that displays the hexagonal montage into a Panel control. That control's AutoScroll property is set to true, so it automatically displays scroll bars if picGrid is too large to fit.

That's all there is to it. The picGrid control reports mouse positions in its normal coordinate system even if you have use the panel to move the picture to a new location. The program then uses the mouse clicks to determine which hexagonal area you have clicked.

Download the example to experiment with it and to see additional details.

© 2009-2023 Rocky Mountain Computer Consulting, Inc. All rights reserved.