Click here to Skip to main content
15,794,275 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,
I have DataGridView(DGV) in its 1st column of every row [with DGV.GetCellDisplayRectangle(...) menthod) I placed UserControl(UC). But when row counts increases it adds scroll to DGV
And then i'm not able to move UC to scrolled location, Because DGV.GetCellDisplayRectangle(...) returns Rectangle.X = 0 and Rectangle.Y=0 every time (If DGV.Cell is visible).
Why? Now how to solve this problem?

void dgvMapper_Scroll(object sender, ScrollEventArgs e)

                int intCnt = 0;
                foreach (UserControl ucEL)
                    ucEL.Visible = false;
                    Rectangle rect = this.dgvMapper.GetCellDisplayRectangle(1, intCnt, false);
                    ucEL.Location = rect.Location;

                    ucEL.Size = rect.Size;
                    if (!(rect.X==0 && rect.Y==0 && rect.Height==0))
                        ucEL.Visible = true;



Updated 15-Jan-10 20:12pm

1 solution

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