private void DrawPageNumberinRect(Rectangle rect, int pageNo, PaintEventArgs pe)
        {
            if (rect.Width > 100 && rect.Height > 100)
            {
                string s = string.Format("page {0}", pageNo);
                using (Font f = new Font(grid.Font.FontFamily, 40))
                {
                    Size      sz = TextRenderer.MeasureText(s, f);
                    Rectangle r  = GridUtil.CenterInRect(rect, sz);

                    DrawPageNumberEventArgs e = new DrawPageNumberEventArgs(pe, r, s);
                    OnDrawPageNumber(e);
                    if (!e.Cancel)
                    {
                        using (Brush b = new SolidBrush(TextColor))
                        {
                            Region region = pe.Graphics.Clip;
                            pe.Graphics.Clip = new Region(grid.RangeInfoToRectangle(grid.ViewLayout.VisibleCellsRange));
                            pe.Graphics.DrawString(s, f, b, r);
                            pe.Graphics.Clip = region;
                        }
                    }
                }
            }
        }
 protected virtual void OnDrawPageNumber(DrawPageNumberEventArgs e)
 {
     if (DrawPageNumber != null)
     {
         DrawPageNumber(grid, e);
     }
 }