Israel

Israel

  • 631
  • 1.3k
  • 217.4k

Datagrid Preview doesnt move

Nov 22 2015 7:01 PM
Hi!
 
Please I need to move my datagrid printpreview a little bit to bottom as I need. 
In real, when the datagrid drawed appear on my printpage. The design can move anytime I want. But not the datagrid's content. The content Its freezing (I am trying to resolv since many days). 
 
Anyone could help PLEASE. This is my code:
 
#region column1
e.Graphics.FillRectangle(Brushes.LightGray, new Rectangle(100, 90, dvgEntradasDespesas.Columns[0].Width, dvgEntradasDespesas.Rows[0].Height));
e.Graphics.DrawRectangle(Pens.Black, 100, 90, dvgEntradasDespesas.Columns[0].Width, dvgEntradasDespesas.Rows[0].Height);
e.Graphics.DrawString(dvgEntradasDespesas.Columns[6].HeaderText, dvgEntradasDespesas.Font, Brushes.Black, new RectangleF(100, 90, dvgEntradasDespesas.Columns[0].Width, dvgEntradasDespesas.Rows[0].Height), str);
#endregion
 
#region column2
e.Graphics.FillRectangle(Brushes.LightGray, new Rectangle(200, 90, dvgEntradasDespesas.Columns[0].Width, dvgEntradasDespesas.Rows[0].Height));
e.Graphics.DrawRectangle(Pens.Black, 200, 90, dvgEntradasDespesas.Columns[0].Width, dvgEntradasDespesas.Rows[0].Height);
e.Graphics.DrawString(dvgEntradasDespesas.Columns[7].HeaderText, dvgEntradasDespesas.Font, Brushes.Black, new RectangleF(200, 90, dvgEntradasDespesas.Columns[0].Width, dvgEntradasDespesas.Rows[0].Height), str);
#endregion
 
 
width = 100 + dvgEntradasDespesas.Columns[0].Width;
height = 100;
//variable i is declared at class level to preserve the value of i if e.hasmorepages is true
while (i < dvgEntradasDespesas.Rows.Count)
{
if (height > e.MarginBounds.Height)
{
height = 100;
width = 300;
e.HasMorePages = true;
return;
}
height += dvgEntradasDespesas.Rows[i].Height;
e.Graphics.DrawRectangle(Pens.Black, 100, height, dvgEntradasDespesas.Columns[0].Width, dvgEntradasDespesas.Rows[0].Height);
e.Graphics.DrawString(dvgEntradasDespesas.Rows[i].Cells[6].FormattedValue.ToString(), dvgEntradasDespesas.Font, Brushes.Black, new RectangleF(100, height, dvgEntradasDespesas.Columns[0].Width, dvgEntradasDespesas.Rows[0].Height), str);
e.Graphics.DrawRectangle(Pens.Black, 100 + dvgEntradasDespesas.Columns[0].Width, height, dvgEntradasDespesas.Columns[0].Width, dvgEntradasDespesas.Rows[0].Height);
e.Graphics.DrawString(dvgEntradasDespesas.Rows[i].Cells[7].FormattedValue.ToString(), dvgEntradasDespesas.Font, Brushes.Black, new RectangleF(100 + dvgEntradasDespesas.Columns[0].Width, height, dvgEntradasDespesas.Columns[0].Width, dvgEntradasDespesas.Rows[0].Height), str);
 
 
 
 

Answers (4)