D
Derrick
Hello all;
I have a UserControl (named "GridDisplay") onto which I'm drawing a grid.
What I need to know is, as the grid height grows beyond the bounds of the
UserControl , how to I get the UserControl to show it's scrollbars, so I can
let the user scroll to the bottom of my grid (and horizontally as well, if
need be)? I know it does this automatically when there are controls on the
UserControl . I have the UserControl's dockstyle set to "Fill" on the host
Form, and AutoScroll set to True.
Here's my paint code:
private void GridDisplay_Paint(object sender, PaintEventArgs e)
{
Point DrawStartPoint = new Point(10,10);
Size cellSize = new Size(30,15);
numCols = 20; //just an example number
numRows = 200; //just an example number
Graphics g = e.Graphics;
g.Clear(this.BackColor);
for(int j = 0; j < numRows; j++)
{
int yLoc = DrawStartPoint.Y + j*cellSize.Height;
Rectangle[] cells= new Rectangle[numCols];
for(int i = 0; i < this.numCols; i++)
{
int xLoc = DrawStartPoint.X + i*cellSize.Width;
Point p = new Point(xLoc, yLoc);
cells = new Rectangle(p, ByteDrawSize);
}
g.DrawRectangles(new Pen(Color.Black), cells);
}
}
I have a UserControl (named "GridDisplay") onto which I'm drawing a grid.
What I need to know is, as the grid height grows beyond the bounds of the
UserControl , how to I get the UserControl to show it's scrollbars, so I can
let the user scroll to the bottom of my grid (and horizontally as well, if
need be)? I know it does this automatically when there are controls on the
UserControl . I have the UserControl's dockstyle set to "Fill" on the host
Form, and AutoScroll set to True.
Here's my paint code:
private void GridDisplay_Paint(object sender, PaintEventArgs e)
{
Point DrawStartPoint = new Point(10,10);
Size cellSize = new Size(30,15);
numCols = 20; //just an example number
numRows = 200; //just an example number
Graphics g = e.Graphics;
g.Clear(this.BackColor);
for(int j = 0; j < numRows; j++)
{
int yLoc = DrawStartPoint.Y + j*cellSize.Height;
Rectangle[] cells= new Rectangle[numCols];
for(int i = 0; i < this.numCols; i++)
{
int xLoc = DrawStartPoint.X + i*cellSize.Width;
Point p = new Point(xLoc, yLoc);
cells = new Rectangle(p, ByteDrawSize);
}
g.DrawRectangles(new Pen(Color.Black), cells);
}
}