DataGridView mouse wheel scrolling stopped working

I have a DataGridView in my application and I cannot scroll it with the mouse. It used to work fine. I'm not sure what I did to call this because I noticed this recently after I made a few code changes.

I am not sending any code because there are lines over 2 thousand, and I am not sure where the error may be.

Any ideas that might trigger this? If you need any code, I can change the question later.

+4
source share
1 answer

Almost certainly a problem arises because the DataGridView has lost focus. This may be due to the fact that another control in your form requires focus or your form is set by default to give a different control focus.

You can make the DataGridView have focus. If you want to emulate standard Microsoft Windows behavior that allows you to scroll the mouse wheel while the mouse is running over a control, simply use the code below.

private void SettingsGrid_MouseEnter(object sender, EventArgs e) { dataGridView1.Focus(); } 

If you want to scroll the grid no matter which control has focus, then the code will be similar to the previous one with a small beak of settings.

+6
source

All Articles