Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

  • 3 years later...
Posted
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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...