For a form graphics rendering, override the method
OnPaint
and call your rendering method in it:
protected void OnPaint(PaintEventArgs e) {
int row =
int column =
int width =
DrawCaroBoard(e.Graphics, row, column, width);
}
Please see
http://msdn.microsoft.com/en-us/library/3e40ahaz.aspx[
^].
Now, scrolling. Pay attention that the class
System.Windows.Forms.Form
is derived from the class
System.Windows.Forms.ScrollableControl
, so scrolling is already created for you. As
Panel
also inherits the properties and behavior of this class, you can scroll its content the same way. Please see:
http://msdn.microsoft.com/en-us/library/system.windows.forms.scrollablecontrol.aspx[
^].
The idea is to use
AutoScroll
and
AutoScrollMinSize
. When the actual size becomes less then "auto", vertically or horizontally, the appropriate scroll bar appears (or both), helping to scroll the control's content to show the whole content which is assumed to be of the minimal size.
—SA