Focus on Datagridview triggers scroll

anica

Newcomer
Joined
Dec 23, 2003
Messages
4
Hello,

I have a datagridview control on panel with other controls. This panel sits on a form. Panels AutoScroll property is set to True and the datagridview's ScrollBars property is set to None. I am calulating the height of the grid.
As soon as we set focus on the datagridview say by clicking on it the grid it places itself on top of the panel. It jumps up. As a result i have to scroll up to view the other controls.
Here is the code -

for (int i = 0; i < 100; i++)
{
this.dataGridView1.Rows.Add(i.ToString());
}
int ht = this.dataGridView1.ColumnHeadersHeight;
ht += ((this.dataGridView1.RowTemplate.Height - 1) * 100);

this.dataGridView1.Height = ht;


Why does focusing on the grid trigger scrolling?

Thanks,
Anica
 
Hello,

I have a datagridview control on panel with other controls. This panel sits on a form. Panels AutoScroll property is set to True and the datagridview's ScrollBars property is set to None. I am calulating the height of the grid.
As soon as we set focus on the datagridview say by clicking on it the grid it places itself on top of the panel. It jumps up. As a result i have to scroll up to view the other controls.
Here is the code -

for (int i = 0; i < 100; i++)
{
this.dataGridView1.Rows.Add(i.ToString());
}
int ht = this.dataGridView1.ColumnHeadersHeight;
ht += ((this.dataGridView1.RowTemplate.Height - 1) * 100);

this.dataGridView1.Height = ht;


Why does focusing on the grid trigger scrolling?

Thanks,
Anica

Hi Anica,

Did you ever solve this problem? I'm having the exact same problem. My grid is longer than the display area and whenever it receives focus it will scroll the parent control to show it's row header. So annoying.

John
 
Back
Top