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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is the first event when I close a Form?

Status
Not open for further replies.

KiaKia

Programmer
Mar 30, 2008
59
US
Hi,
What I need to know is the first event which is executing right after I click the X but in my form's control box.

Here is the whole story:
I get the following error message when Clicking on X but of its control box:
System.ArgumentException: DataGridViewComboBoxCell value is not valid.

I know the filter that I set on this comboBox is causing the problem, so I need to reset this filter before I leave the form.
I tried to add the following code to "FormClosing" and "FormClosed" event, but the error keeps pupping up.
Me.MyBindingSource.Filter = ""

It seems that there are other events that are fiering before execution of my code.

Any comment and possible solution is highly appreciated.


Thanks,
Kia


 
Do you have any event handler for the DataGridViewComboBox object? Or the DataGridView itself?
If so, you need to put additional check before executing the rest of the lines.
 

I agree with mansii; it sounds like something is firing from an event in either your DataGridViewComboBox, DataGridView or the data source. If this is coming from somthing like a validation or lostfocus event, anything in the FormClosing and FormClosed events are coming after the fact.
 
Think about "Me.Validate" to validate the data before you close.

________________________________________________________
Zameer Abdulla
Help to find Missing people
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top