I am trying to draw a number of nearly identical Image with Graphics.DrawImage()
, taken from a Bitmap, into a PictureBox
docked into a Panel
and Panel.AutoScroll
has been set into True
. I know they are supposed to clip when they are drawn outside the PictureBox
bound (by i mean bound is the PictureBox
's Width and Height) but let say i can redraw those images when the PictureBox
is resized, but that is not my real problem.
//This is my code which draw 40 x 40 circle, node alike, bitmaps into PictureBox
private void ValButton_Click(object sender, EventArgs e)
{
Graphics gr = picBox.CreateGraphics();
for (int i = 0; i < 101; i++)
{
gr.DrawImage(nodeBmp, (imgDisplay.Width / 2) + (i * 20), 80);
}
gr.Dispose();
}
when i resize the Form, by stretching the Form or by Maximizing the Form, the PictureBox
is resized but the image is left not changed, not moved and still clipped, and no ScrollBar shown
^There should be 100 circles there, and yet no ScrollBar
^stretched the Window, Still no ScrollBar. The X and Y label down there shown the current Width and Height of the
PictureBox
Also, i have tried to change the PictureBox.SizeMode
to AutoSize
and Normal
still no change.
So, are the whole trial i have attempt wrong ? if so, what are the correct way to achieve ScrollBar for a Drawn images with Graphics
?
Thank you.