Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGridView Cell Clearing

Status
Not open for further replies.

gharabed

Programmer
Sep 7, 2001
251
US
I have a DataGridView (VS 2008) that has a cell being cleared when I push a button on my form when it shouldn't be. I can see it clearing when I push the mouse button down and before I lift my finger off the mouse button. I can also see, through debug statements, that the value is still set after the rowValidated event, but by the time it gets to the button "Click" event it has cleared.

Is there some way in the debugger to have the code stop executing when that DGV cell value changes so I can see where it is happening? Also, is there any way to know all of the events being fired from the time I click on the button?
 
I would suggest putting a break point on the MousDown event of the button and stepping through the code.
 
I added a debug statement to the MouseDown event. I've put some handlers in and I can see the order in which they fire and when they clear.

CellValidating - Value Exists
RowValidating - Value Exists
RowValidated - Value Exists
MouseDown - Value CLEARED

Now this is really interesting...I'm wondering if I'm not hitting some sort of bug in VB.net. If I step through the code from RowValidated to MouseDown, I can see the cell is set in RowValidated and then cleared by the time it gets to MouseDown. Here is the code:

Code:
    Private Sub ClassesDGV_RowValidated(ByVal sender As System.Object, 
                                        ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles ClassesDGV.RowValidated
        Debug.WriteLine("RowValidated..." + Me.ClassesDGV.Rows(0).Cells("classStartDate").Value)
    End Sub

    Private Sub SearchBtn_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles SearchBtn.MouseDown
        Debug.WriteLine("MouseDown..." + Me.ClassesDGV.Rows(0).Cells("classStartDate").Value)
    End Sub


These events are fired in the exact order show in the code above. As soon as it hits the end of the RowValidated code it steps right in to the MouseDown code. How could the cell clear between those two events if no code is being executed?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top