Hi Shabnam,
Quote:
Unable to cast object of type 'System.EventArgs' to type 'System.Windows.Forms.DataGridViewCellEventArgs'.
|
Code:
'Get the selected airplane Dim plane As Airplane = DirectCast(cmbLineNumberTo.SelectedItem, Airplane)
'Display the airplane information
dgvAPList.DataSource = plane.AirplaneStallAssignments
I don't think I understand this. If you don't get an error on the first line, then the selected object must be an Airplane as you intend.
I'm guessing that AirplaneStallAssignments is a collection or table (something that is enumerable)? I don't see how making that assignment should lead to that particular "unable to cast" error.
Do you have any event handlers registered for the dgvAPList control? Perhaps setting its DataSource makes it raise an event and it is actually the event handler that is throwing the exception?
The other thing that might make sense is if there's an automatically generated event handler somewhere (perhaps created by EF). If it's code is marked with the right attributes, it wouldn't show up in the debugger, but it could still throw this exception.
You might try searching the project for DataGridViewCellEventArgs and see if you find anything.
If you can't find a likely cause for this, you can zip the project up (without the bin and obj directories) and attach it to this post (or email it to me) and I'll try to take a closer look.