Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Datagridview crashes when scrolling if mouse button is pressed.

Avatar of rowternet
rowternet asked on
Visual Basic.NET
6 Comments1 Solution625 ViewsLast Modified:
Hi,

I have a datagridview and a timer on it.
This timer refreshes every 12 seconds.
Whenever i use the horizontal scroll if the mouse button is pressed ,the datagridview crashes and i have to restart teh application.

This is the code i have in the timer tick event.
 Private Sub Sh_Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Sh_Timer1.Tick
        Do While Not bFormClose
            If MouseButtons = Windows.Forms.MouseButtons.None Then #### if mouse is not pressed
                If Not bRowBeingEdited Then #### if row is not being edited
                    refreshDGVMethod() #### refresh the datagrid.
                    Exit Sub
                ElseIf MouseButtons = Windows.Forms.MouseButtons.Left Then
                    Exit Sub
                End If
            End If

        Loop
    End Sub

Not sure why i am getting the problem.I do not have anything written in the scroll event.

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Tom Beck
Commented:
This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answers