Reputation: 1733
I have a DataGridView inside a panel. The scrolling is disabled on the DataGridView but instead is done on the panel. By doing so I achieve pixel based scrolling of the DataGridView. I scroll as following:
dgvPanel.AutoScrollPosition = value;
However, the problem is that after changing the scroll bar position, if I click on the DataGridView - it jumps back to the beginning of the list. What could cause this?
Upvotes: 5
Views: 611
Reputation: 81620
Replace the panel you are using with this one, which overrides the ScrollToControl function the default panel is using to make sure the control is visible:
public class PanelEx : Panel {
protected override Point ScrollToControl(Control activeControl) {
//return base.ScrollToControl(activeControl);
return this.AutoScrollPosition;
}
}
Upvotes: 7