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?
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;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With