嘿frenz,在我的项目中,我将行与细胞绘画合并。它工作正常。但是当我使用滚动条时,它会提供随机输出。即该合并单元格上的数据转到数据网格视图的标题。任何解决方案。代码如下:
private void Daywisegrid_Paint(object sender, PaintEventArgs e)
{
for (int k = 0; k < BranchIndex.Count; k++)
{
Font fnt = new Font("Arial", 10, FontStyle.Bold, GraphicsUnit.Point);
Rectangle rct1 = new Rectangle((Daywisegrid.GetColumnDisplayRectangle(0, true).X),
(Daywisegrid.GetColumnDisplayRectangle(0, true).Y),
Daywisegrid.GetColumnDisplayRectangle(0, true).Width - 1,
(Daywisegrid.GetRowDisplayRectangle((Daywisegrid.Rows.Count - 1), true).Top -
Daywisegrid.GetRowDisplayRectangle((Daywisegrid.Rows.Count - 1), true).Height));
Rectangle rct = Daywisegrid.GetRowDisplayRectangle(Convert.ToInt32(BranchIndex[k]), true);
rct.Height -= 1;
SizeF s = e.Graphics.MeasureString("Branch", Daywisegrid.Font);
float lefts = (rct.Width / 2) - (s.Width / 2);
float tops = rct.Top+((rct.Height/2)-(s.Height / 2));
e.Graphics.FillRectangle(Brushes.White, rct);
e.Graphics.DrawString(BranchName[k].ToString(), fnt, Brushes.Black,0, tops);
}
}