Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I'm trying to merge 5 cell in CellPainting event of datagridview with following code..

e.PaintBackground(e.ClipBounds, false);
int index = 1;//Unchecked image
int FirstRow = e.RowIndex;

Rectangle r_image = this.dg_admindata.GetCellDisplayRectangle(dg_admindata.ColumnCount - 1, e.RowIndex, true);

int w_2nd = this.dg_admindata.GetCellDisplayRectangle(dg_admindata.ColumnCount - 1, e.RowIndex + 1, true).Height;

int w_3rd = this.dg_admindata.GetCellDisplayRectangle(dg_admindata.ColumnCount - 1, e.RowIndex + 2, true).Height;

int w_4th = this.dg_admindata.GetCellDisplayRectangle(dg_admindata.ColumnCount - 1, e.RowIndex + 3, true).Height;

int w_5th = this.dg_admindata.GetCellDisplayRectangle(dg_admindata.ColumnCount - 1, e.RowIndex + 4, true).Height;

r_image.Width = r_image.Width - 1;
r_image.Height = r_image.Height + w_2nd + w_3rd + w_4th + w_5th - 1;

Color clrBackColor = Color.White;

e.Graphics.FillRectangle(new SolidBrush(clrBackColor), r_image);

e.Graphics.DrawImageUnscaled(imageList2.Images[index], e.CellBounds.X + 25, e.CellBounds.Y + 2);

e.Handled = true;

but this fill rectangle on two cells only.

How to fill for 5 cells ?

if any idea please share.

Thanks..
Posted
Comments
Sinisa Hajnal 25-Feb-15 4:16am    
Check height values, the code seems fine. I'd say you have size or scale problem with r_image. Please use CODE tab to format your question. Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900