Answered by:
DataGridView LostFocus Event

Question
-
I have a (seemingly) strange issue. I want to do something when a datagridview loses focus, but the event doesn't fire. I know have focus to begin with because the tab key functions within the dgv as I expect. What am I doing wrong?
Thanks
Thanks,
Corey Furman @ Facebook
______________________________________________________
Please mark posts as answer or helpful when they are.Tuesday, April 17, 2012 9:18 PM
Answers
-
Private Sub dgvReceivings_Leave(sender As Object, e As System.EventArgs) Handles dgvReceivings.Leave dgvReceivings.Visible = False End Sub Private Sub dgvReceivings_LostFocus(sender As Object, e As System.EventArgs) Handles dgvReceivings.LostFocus dgvReceivings.Visible = False End Sub
These two events do not fire when I click on the form itself. One of them fires when I click on another control.
My ultimate goal is to get a dgv to behave like a combobox dropdown, which collapses the dropdown when you do click on the form background. I think I'll just add a click event for the form...
Thanks,
Corey Furman @ Facebook
______________________________________________________
Please mark posts as answer or helpful when they are.- Marked as answer by Corey Furman Thursday, April 19, 2012 11:20 AM
Wednesday, April 18, 2012 12:26 AM -
These two events do not fire when I click on the form itself. One of them fires when I click on another control.
Please call me Frank :)
- Proposed as answer by Mark Liu-lxf Thursday, April 19, 2012 2:35 AM
- Marked as answer by Corey Furman Thursday, April 19, 2012 11:20 AM
Wednesday, April 18, 2012 2:35 AM
All replies
-
How do you know you are loosing focus on the DGV? Do you select another control? Does that control fire its gotfocus event?
ebassador
"Find it, fix it, move on."Tuesday, April 17, 2012 10:10 PM -
Corey,
Which event handler are you using? I assume the ".Leave" event? If so, put a breakpoint in and follow what it's doing and when - you'll probably discover why it's not doing what you want that way.
Good luck with your project. :)
Please call me Frank :)
Tuesday, April 17, 2012 10:13 PM -
Private Sub dgvReceivings_Leave(sender As Object, e As System.EventArgs) Handles dgvReceivings.Leave dgvReceivings.Visible = False End Sub Private Sub dgvReceivings_LostFocus(sender As Object, e As System.EventArgs) Handles dgvReceivings.LostFocus dgvReceivings.Visible = False End Sub
These two events do not fire when I click on the form itself. One of them fires when I click on another control.
My ultimate goal is to get a dgv to behave like a combobox dropdown, which collapses the dropdown when you do click on the form background. I think I'll just add a click event for the form...
Thanks,
Corey Furman @ Facebook
______________________________________________________
Please mark posts as answer or helpful when they are.- Marked as answer by Corey Furman Thursday, April 19, 2012 11:20 AM
Wednesday, April 18, 2012 12:26 AM -
These two events do not fire when I click on the form itself. One of them fires when I click on another control.
Please call me Frank :)
- Proposed as answer by Mark Liu-lxf Thursday, April 19, 2012 2:35 AM
- Marked as answer by Corey Furman Thursday, April 19, 2012 11:20 AM
Wednesday, April 18, 2012 2:35 AM