anica Posted May 12, 2006 Posted May 12, 2006 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 Quote
coffeejohn Posted May 26, 2009 Posted May 26, 2009 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 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.